Push all local branches to origin in git [duplicate]
Solution 1:
Have you tried
git push --all -u
The git man states
--all
Instead of naming each ref to push, specifies that all refs under refs/heads/ be pushed.
-u, --set-upstream
For every branch that is up to date or successfully pushed, add upstream (tracking) reference,
the -u
is useful if you intent to pull from these branches later
Solution 2:
git push <remote_name> '*:*'
The command is intuitive in that it specifies the :
. The one on the left of :
indicates the name of the local branch and the one on the right specifies the remote branch. In your case, we want to map with the same name and thus the command.
The *:*
tells git that you want to push every local branch to remote with the same name on remote. Thus if you have a branch named my_branch
you will have a remote branch named <remote_name>/my_branch
.
So typically you would do git push origin '*:*'
and you would find every local branch with the same name in the remote, which you can confirm by git branch -r
which will show you all the remote branches.
Solution 3:
You can use a refspec that tells git to push all your branches:
git push origin 'refs/heads/*:refs/heads/*'