back to notes

Git 2.0 push.default

"warning: You did not specify any refspecs to push, and the current remote warning: has not configured any push refspecs. The default action in this warning: case is to push all matching refspecs, that is, all branches warning: that exist both locally and remotely will be updated. This may warning: not necessarily be what you want to happen. warning: warning: You can specify what action you want to take in this case, and warning: avoid seeing this message again, by configuring 'push.default' to: warning: 'nothing' : Do not push anything warning: 'matching' : Push all matching branches (default) warning: 'tracking' : Push the current branch to whatever it is tracking warning: 'current' : Push the current branch"

WTF?

"The default behavior of bare git push with no arguments has traditionally been non-intuitive: All branches were sent to the remote as long as their name matched both locally and remotely. That’s what the matching option meant.

In Git 2.0 the default has been changed to simple which is narrower in scope – more specific and more intuitive – it will now only push:

  • The current branch to the branch with the same name only when the current branch is set to integrate with that remote branch on the same remote;

  • The current branch to the branch with the same name, if you are pushing to a remote that is not where you usually fetch from."

To change the default behaviour of git push without argument:

git config push.default VALUE

where VALUE is:

  • nothing: do nothing (make the user say what they mean)
  • matching: push all local branches for which a remote branch of the same name exists
  • upstream: push only the current branch, push it to its upstream, making push and pull symmetric
  • simple: like upstream, but only if the branch names match (will become default in 2.0)
  • current: push just the current branch"


last updated february 2016