[ACCEPTED]-Push all local branches to origin in git-git

Accepted answer
Score: 102

Have you tried

git push --all -u 

The git man states

--all 6

Instead of naming each ref to push, specifies 5 that all refs under refs/heads/ be pushed.

-u, --set-upstream 4

For every branch that is up to date or successfully 3 pushed, add upstream (tracking) reference,

the 2 -u is useful if you intent to pull from these 1 branches later

Score: 12
git push <remote_name> '*:*'

The command is intuitive in that it specifies 13 the :. The one on the left of : indicates 12 the name of the local branch and the one 11 on the right specifies the remote branch. In 10 your case, we want to map with the same 9 name and thus the command.

The *:* tells git 8 that you want to push every local branch 7 to remote with the same name on remote. Thus 6 if you have a branch named my_branch you will have 5 a remote branch named <remote_name>/my_branch.

So typically you 4 would do git push origin '*:*' and you would find every local 3 branch with the same name in the remote, which 2 you can confirm by git branch -r which will show you 1 all the remote branches.

Score: 4

You can use a refspec that tells git to push all 1 your branches:

git push origin 'refs/heads/*:refs/heads/*'

More Related questions