Why is pushing to matching the default in Git?

As mentioned in “Warning: push.default is unset; its implicit value is changing in Git 2.0”:

matching means git push will push all your local branches to the ones with the same name on the remote. This makes it easy to accidentally push a branch you didn’t intend to.

And that is not a best practice: you shouldn’t push all your branches.
Most of them can be private branches for test or internal dev only.

simple (Git 2.0 default) means git push will push only the current branch to the one that git pull would pull from, and also checks that their names match.

By default, it pushes the branch you are working on, only if said branch exists on the remote side with the same name (or if you create it explicitly).

You can find more discussion about that policy change in “[git push – Default behavior?].2”.

I describe the other policies in “git – push current vs. push upstream (tracking)”.


That new default policy is now merged to main (commit 289ca27) and states it is the new default in commit 11037ee:

We promised to change the behavior of lazy “git push [there]” that does not say what to push on the command line from “matching” to “simple” in Git 2.0.

This finally flips that bit.

Leave a Comment

tech