Can I keep git from pushing the master branch to all remotes by default?
Posted
by
Curtis
on Stack Overflow
See other posts from Stack Overflow
or by Curtis
Published on 2012-09-05T14:19:25Z
Indexed on
2012/09/05
15:38 UTC
Read the original article
Hit count: 170
I have a local git repository with two remotes ('origin' is for internal development, and 'other' is for an external contractor to use). The master branch in my local repository tracks the master in 'origin', which is correct. I also have a branch 'external' which tracks the master in 'other'. The problem I have now is that my master brach ALSO wants to push to the master in 'other' as well, which is an issue. Is there any way I can specify that the local master should NOT push to other/master?
I've already tried updating my .git/config file to include:
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "external"]
remote = other
merge = refs/heads/master
[push]
default = upstream
But remote show
still shows that my master is pushing to both remotes:
toko:engine cmlacy$ git remote show origin
Password:
* remote origin
Fetch URL: <REPO LOCATION>
Push URL: <REPO LOCATION>
HEAD branch: master
Remote branches:
master tracked
refresh-hook tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
Those are all correct.
toko:engine cmlacy$ git remote show other
Password:
* remote other
Fetch URL: <REPO LOCATION>
Push URL: <REPO LOCATION>
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
external merges with remote master
Local ref configured for 'git push':
master pushes to master (local out of date)
That last section is the problem. 'external' should merge with other/master, but master should NEVER push to other/master. It's never gong to work.
© Stack Overflow or respective owner