Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change which GitHub project I forked from?

Tags:

git

branch

github

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 
like image 416
LanguagesNamedAfterCofee Avatar asked Apr 21 '11 20:04

LanguagesNamedAfterCofee


2 Answers

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.
like image 95
Castrohenge Avatar answered Oct 13 '22 04:10

Castrohenge


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.

like image 29
poke Avatar answered Oct 13 '22 06:10

poke