git: disable automatic pushing to a certain remote branch

梦想的初衷 提交于 2020-01-02 01:39:05

问题


When I run git push, my local branch some_branch is pushed to a remote branch some_remote\some_branch.

When I run git remote show some_remote I get:

Local refs configured for 'git push':
[cut]
some_branch         pushes to some_branch

I don't want this. How do I remove this entry?


回答1:


Perhaps the simplest answer is to rename your local branch some_branch to another name, e.g. with:

git branch -m some_branch a_branch_name_not_present_on_some_remote

The reason for this is that git push by default pushes each branch to a branch with a matching name on the remote, if such a branch exists there. If you don't like this behaviour in general, you have to change the push.default config option. For example, you could do:

git config --global push.default tracking
git branch --set-upstream some_branch origin/totally_different_branch

I wrote a bit more here about the behaviour of git push where you don't specify the refspec explicitly.




回答2:


Easy way - edit it out of your .git/config file.



来源:https://stackoverflow.com/questions/6083564/git-disable-automatic-pushing-to-a-certain-remote-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!