Let's say that I have A LOT of local branches in my git not pushed on the remote repository.
How can I push all of them to origin with a single command?
Let's say that I have A LOT of local branches in my git not pushed on the remote repository.
How can I push all of them to origin with a single command?
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
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.