i have cloned Repo1 from github to my local. then added url of Repo2 using git remote add new-origin command.
Repo1 contains 100 branches, so i cant checkout for each and every branch
i am trying to push all the branches to Repo2 using git push new-origin --all
but only master branch of Repo1 is pushed to Repo2.
HOW CAN I PUSH ALL THE 100 BRANCHES OF Repo1 TO Repo2 without checking out to all the branches of Repo1
NOTE: i dont want to use bare or mirror repository
I think it will only push all the local branches, so I guess you first have to checkout all of origin
's branches and then push them.
does this work?
git branch # should only show master
# check-out every single branch
git branch -a | grep origin | sed 's|remotes/origin/||' | xargs -I {} git checkout {}
git branch # should now show all branches
git push new-origin --all
(watch out - that's also push local stuff that wasn't in origin
)
------ after comment - try this maybe -----
git branch -a | grep origin \
| sed 's|remotes/origin/||' \
| xargs -I {} git push new-origin origin/{}:refs/heads/{}
that should just list all of the branches on origin, and then push them all to new branches with the same name on new-origin
If there are spaces in any branch names (if that is possible) it probably won't work.
to see what it will do before trying, change the last line to this:
| xargs -I {} echo git push new-origin origin/{}:refs/heads/{}
then if you are happy, remove echo
, and see