Default behavior of “git push” without a branch specified

前端 未结 12 1197
眼角桃花
眼角桃花 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:00

    You can set up default behavior for your git with push.default

    git config push.default current
    

    or if you have many repositories and want the same for all then

    git config --global push.default current
    

    The current in this setup means that by default you will only push the current branch when you do git push

    Other options are:

    • nothing : Do not push anything
    • matching : Push all matching branches (default)
    • tracking : Push the current branch to whatever it is tracking
    • current : Push the current branch

    UPDATE - NEW WAY TO DO THIS

    As of Git 1.7.11 do the following:

    git config --global push.default simple
    

    This is a new setting introduced that works in the same way as current, and will be made default to git from v 2.0 according to rumors

提交回复
热议问题