How do I change which GitHub project I forked from?

GitGithubBranch

Git Problem Overview


I forked a project, made some changes, and got a pull request accepted. But now, the project I forked moved to another repository and is a fork of that repository.

That is:

Original -> MyFork

Now:

NewOriginal -> Original -> MyFork

How would I get it to the following?

NewOriginal -> MyFork

Git Solutions


Solution 1 - Git

NOTE: The following solution is incomplete as you'll lose all wiki content and issues specific to your fork.

You can achieve this using the following steps:

  1. Pull down all branches and tags from your existing fork.
  2. Delete your repository on GitHub.
  3. Fork from the new repository.
  4. Update the remote URL if necessary.
  5. Push all your local branches and tags to the new repository.

Solution 2 - Git

Locally you can just change the target of the original repository is located at. Usually that repository is called upstream, so you would do this:

git remote set-url upstream git://example.com/NewOriginal.git

Depending on what host you are using (that is, where your fork is located), there might be some additional internal links, you can't change so easily. For example on Github, the fork is directly linked to the original you forked from. In that case you need to fork the new project again, and work with the new fork.

In that case however you can easily change the URL of the origin repository as well, and just push everything you changed before in your old fork into your new fork.

Solution 3 - Git

Update the remote URL in your repository:

git remote set-url origin <url to NewOriginal, e.g. git://…/bla.git>

Solution 4 - Git

Assuming you performed the proper forking and adding upstream see githubHelpOnFork ; to just change the upstream URL, do:

  1. verify what your current upstream and origin looks like :

    git remote -v
    
  2. if you see upstream listed and you want just change its url, do what @poke suggested (if not follow the helpGithub link above to add a new upstream) :

    git remote set-url upstream git://example.com/NewOriginal.git
    
  3. then verify that upstream is pointing to the new URL

    git remote -v
    

Solution 5 - Git

It appears that Github refers to this as "rerouting" a fork. This can be requested as a manual human action, as a support request.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLanguagesNamedAfterCofeeView Question on Stackoverflow
Solution 1 - GitCastrohengeView Answer on Stackoverflow
Solution 2 - GitpokeView Answer on Stackoverflow
Solution 3 - GitknittlView Answer on Stackoverflow
Solution 4 - Gituser2651178View Answer on Stackoverflow
Solution 5 - GitjkmartinView Answer on Stackoverflow