问题
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