4

On github, I've forked a project from its original source original/project-name so now I have a remote repo on github myusername/project-name. I would now like to switch my github repo to use a contributors fork contributor/project-name. How can I do this?

askvictor
  • 3,361
  • 3
  • 30
  • 41

2 Answers2

4

As already noted in the comments, it's as simple as

git remote set-url origin https://github.com/contributor/project-name.git

An alternative you may want to consider is to create a second remote for the fork.

git remote add fork https://github.com/contributor/project-name.git

If you want to keep the fork up-to-date with the original repo, you can refer to my answer to this question.

Community
  • 1
  • 1
Gabriele Petronella
  • 104,800
  • 21
  • 210
  • 229
1

Gabriele's answer provides the quickest and most concise option, but you could alternatively edit the .git/config file to change the remote. Possibly a better choice would be to add another remote all together as done by

git remote add REMOTE_NAME_HERE REMOTE_URL_HERE

i.e.:

git remote add test https://github.com/username/test-project.git

where "test" becomes the name of your new remote. You would then push to the remote repo using "test" instead of "origin"

git push -u test BRANCH_NAME
jonstaff
  • 2,662
  • 2
  • 18
  • 18