Does "git push" push all commits from other branches?

16,662

Solution 1

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.

Solution 2

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

Share:
16,662

Related videos on Youtube

Liglo App
Author by

Liglo App

My name is Bartlomiej Zalewski, I was born in Poland and have been living since 11 years in Germany. I love linguistic but I am also software developer and UI designer. I created the app Liglo with an innovative, sentence-based learning methodology.

Updated on October 11, 2022

Comments

  • Liglo App
    Liglo App over 1 year

    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?

  • VonC
    VonC about 3 years
    @Honey a git push --all, by pushing all branches, would also push all commits.
  • mfaani
    mfaani about 3 years
    even commits on detached heads?
  • VonC
    VonC about 3 years
    @Honey No: as illustrated here (stackoverflow.com/q/35736116/6309), detached heads would not be part if a push.