Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push all remote tracking branches to new remote?

Tags:

git

I have cloned my repo and would like to push all my remote branches (origin/*) to a new remote which I configured. I have tried:

git push anotherRemote --all

but it only pushes the ones that I made a local copy from. When I type:

git branch -r

I see all the branches located on my other remote (which I have not created local copies of). How to I push those to my anotherRemote ?

like image 574
u123 Avatar asked Feb 13 '23 19:02

u123


1 Answers

Simply specify explicitly what you want to push where:

git push anotherRemote refs/remotes/origin/*:refs/heads/*

This will take all remote branches of origin and push them as normal branches on the other remote. (Verify with git fetch anotherRemote; git branch -rv.)

Beware of the --mirror option unless you really understand what it does!

like image 167
michas Avatar answered Feb 17 '23 08:02

michas