Git/Push all branches

From Sidvind
Jump to: navigation, search

Push all local branches[edit]

git push --all REMOTE

Push all branches from one remote to another[edit]

src=origin dst=mirror; git push ${dst} $(for branch in $(git branch --list --remote "${src}/*" | grep -v --regexp='->'); do echo "${branch}:refs/heads/${branch//${src}\/}"; done)

It works by listing all branchs from a given remote using git branch --list --remote and outputs it as SRC/BRANCH:refs/heads/BRANCH (refs/heads/ is needed because the branch isn't local). The rest if just a regular git push.