Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: disable automatic pushing to a certain remote branch

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?

like image 575
lampak Avatar asked May 21 '11 18:05

lampak


1 Answers

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.

like image 171
Mark Longair Avatar answered Nov 06 '22 01:11

Mark Longair