30

If I have many unpushed commits spread among many branches in my local repo, what happens if I type git push? Will all of those commits be pushed or only those which belong to the current branch?

TallTed
  • 9,069
  • 2
  • 22
  • 37
Liglo App
  • 3,719
  • 4
  • 30
  • 54
  • possible duplicate of [git push multiple branches from multiple commits](http://stackoverflow.com/questions/13000563/git-push-multiple-branches-from-multiple-commits) – Oliver Charlesworth Sep 30 '13 at 07:13

2 Answers2

32

No, git push only pushes commits from current local branch to remote branch that you specified in command.

You can tell git to push all branches by setting the --all argument

See the command description

Shimon Rachlenko
  • 5,469
  • 40
  • 51
18

It also depends on your push policies (git config push.default).

As I explain in "git - push current vs. push upstream (tracking)", only the "matching" policy pushes more than the current branch.

push all branches having the same name on both ends.
This makes the repository you are pushing to remember the set of branches that will be pushed out (e.g. if you always push maint and master there and no other branches, the repository you push to will have these two branches, and your local maint and master will be pushed there).

With that policy, only a simple git push is enough to push all (matching) branches.
Without that policy, a git push --all is necessary to force all branches to be pushed.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250