I've forked my project off the wrong project (I forked a fork) and I want to reset my GitHub repository to be forked off of the original. Moving a fork in GitHub involves dropping and reforking AFAIK. The only problem is I want to push my old remote branch refs to the new branch without making local branches because (let's say for the sake of argument) I have 100 different branches and it would take too much time to check out new local versions of each remote branch. (My local branch list is pretty lean but I leave fix branches up on GitHub usually).
Asked
Active
Viewed 237 times
0
-
1I don't completely understand the issue, but have you tried adding a new remote (`git remote add $name $url`) and then running `git push --all` (or `--mirror`)? – Whymarrh Oct 27 '15 at 21:26
-
If I do git branch -a I'll see 1 or 2 branches locally and then 100 branches that say /remotes/repoA/branchName, I want them to show up in branchB as /remotes/repoB/branchName without having to create local branches and do a push --all – lanierhall Oct 27 '15 at 21:33
-
1I think `--mirror` is what you're looking for. Clone the repository you have on disk to a new location using the mirror flag, add the new remote to it, and push it with the mirror flag to the new remote. – Whymarrh Oct 27 '15 at 21:36
1 Answers
1
You can achieve this using right refspec
in git push
(step 4):
- Rename remote-tracking references
refs/remotes/origin/...
torefs/remotes/oldfork/...
by renaming remote:git remote rename origin oldfork
- Drop and re-fork the repo at GitHub
- Re-add
origin
remote:git remote add origin <url>
- Push old branches to new fork:
git push origin 'refs/remotes/oldfork/*:refs/heads/*'
- Remove
oldfork
remote:git remote remove oldfork
If you had your own tags in the original fork, please add --tags
to the git push
command line.

Dmitry Oksenchuk
- 121
- 1
- 4