Default behavior of “git push” without a branch specified

前端 未结 12 1181
眼角桃花
眼角桃花 2020-11-22 05:32

I use the following command to push to my remote branch:

git push origin sandbox

If I say

git push origin

12条回答
  •  一向
    一向 (楼主)
    2020-11-22 06:09

    (March 2012)
    Beware: that default "matching" policy might change soon
    (sometimes after git1.7.10+)
    :

    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

提交回复
热议问题