Git Push Questions - Pedantic
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 wha开发者_开发百科tever 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"?
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 variablepush.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.
Update March 2012: Beware: that default "matching" policy might change soon:
See "Please discuss: what "git push" should do when you do not say what to push?"
In the current setting (i.e.
push.default=matching
),git push
without argument will push all branches that exist locally and remotely with the same name.
This is usually appropriate when a developer pushes to his own public repository, but may be confusing if not dangerous when using a shared repository.The proposal is to change the default to '
upstream
', i.e. push only the current branch, and push it to the branch git pull would pull from.
Another candidate is 'current
'; this pushes only the current branch to the remote branch of the same name.What has been discussed so far can be seen in this thread:
http://thread.gmane.org/gmane.comp.version-control.git/192547/focus=192694
Previous relevant discussions include:
- http://thread.gmane.org/gmane.comp.version-control.git/123350/focus=123541
- http://thread.gmane.org/gmane.comp.version-control.git/166743
To join the discussion, send your messages to: git@vger.kernel.org
精彩评论