tags:

views:

62

answers:

1

I have a master branch and a searchfeature branch in my project. I have pushed the searchfeature branch to the remote repository, all okay so far

When I was working on that branch this morning, I did "git push" I got the following:

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

So I went ahead a did a git config push.default tracking and voila, git push works this no problem, no warning.

What I dont understand is what the difference between "current" and "tracking" is, if you don't do "to whatever it is tracking" then what is the point of "current" - where would it go?, what scenarios would you use current rather than tracking?

Also, what scenarios would one ever use "nothing"?

+2  A: 

Since Git1.6.3:

When the user does not tell "git push" what to push, it has always pushed matching refs.
For some people it is unexpected, and a new configuration variable push.default has been introduced to allow changing a different default behavior.
To advertise the new feature, a big warning is issued if this is not configured and a git push without arguments is attempted.

So the difference between current and tracking is that:

  • current will assume a matching ref (a remote branch with the same name, which may not exist)
  • tracking will based the remote ref to use on the tracking ref associated with that local branch. If it does not track anything, it won't push. But it can track a remote branch with a different name.a remo

Note: default nothing would be useful for read-only repository, made only for content consultation, where no work is supposed to be done and published anywhere.

See also the git push current branch SO question.

VonC