Steve Bennett
Steve Bennett

Reputation: 125995

How to change the source of a Github fork?

I forked a project on Github from source A. Since then, the standard practice is to issue pull requests not to A, but to B. That means every pull request, I have to manually specify the destination of the pull request - a bit tedious.

Is there a way to permanently change the source of my fork?

Upvotes: 20

Views: 10430

Answers (2)

akostadinov
akostadinov

Reputation: 18584

This is not a great addition to @VonC's answer but I did by removing the original fork and then forking from the proper source repo.

If you have local branches you want to keep, just push them to the new fork after the operation. Make sure you have fetched everything from your original fork before deleting it.

IMO this is one of the limitations of github that do not make sense and should be easy to fix given a little goodwill.

Upvotes: 7

VonC
VonC

Reputation: 1323115

I didn't find it at first, but one workaround would be to make another fork, this time from source B, and:

  • clone that new fork.
  • add your initial local clone as a remote
  • fetch from your first local clone, in order to get all your current work
  • push your work to the second fork

At least, this second fork will have the right destination for all pull requests.

Note: the OP Steve Bennett reminds us that:

Github won't allow you to fork the same repository twice.
(That is, you fork A to make C, then someone else forks A to make B - you can't fork C to make D. You get the "Your Fork" button)

So I suggests to do that second fork under another account.

You can manage multiple accounts from your local clones, and that would allow you to bypass the GitHub limitation on multiple forks.

Upvotes: 6

Related Questions