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?
Asked
Active
Viewed 2,173 times
5

askvictor
- 3,621
- 4
- 32
- 45
-
1Use `git remote set-url origin [NEW_REMOTE_URL]` – Alex D Jun 26 '13 at 22:51
-
Something I do when working with forked repos is to create another remote, for easy pull, and keep origin to easy push. – gustavohenke Jun 27 '13 at 00:45
-
@askvictor any luck with the proposed answers? – Gabriele Petronella Jun 28 '13 at 11:44
-
@GabrielePetronella - I don't want to change the remote of my local repository - I want to change the remote repo to a different fork – askvictor Jul 04 '13 at 01:21
2 Answers
6
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
- 106,943
- 21
- 217
- 235
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,672
- 2
- 19
- 18