Reputation: 2507
Provided there are two remote repositories (A, B) and there is a branch master (among others). The first repository A has all branches and the other one B has to have one only masterB.
How can I push local branch master to both remote repositories with a single "git push" command ? (mapping A: master->master; mapping B: master->masterB)
tried so far:
[remote "A"]
url = <urlA>
fetch = +refs/heads/*:refs/remotes/A/*
[remote "B"]
url = <urlB>
fetch = +refs/heads/*:refs/remotes/B/*
push = master:masterB
[branch "master"]
remote = A
merge = refs/heads/master
pushRemote = A
pushRemote = B //this overrides the previous push remote; how can I use both ?
The reference says that multiple 'pushRemote' entries are possible.
Upvotes: 1
Views: 553
Reputation: 1329232
Your tutorial does mention:
Then git allows branches to have multiple
branch.<name>.pushRemote
entries.
You must edit the.git/config
file to set them.
That is not apparent from git config branch.<name>.pushRemote
When on branch , it overrides
branch.<name>.remote
for pushing.
It also overridesremote.pushDefault
for pushing from branch<name>
.When you pull from one place (e.g. your
upstream
) and push to another place (e.g. your own publishing repository), you would want to setremote.pushDefault
to specify the remote to push to for all branches, and use this option to override it for a specific branch.
So managing that case with a script would be easier than tweaking git config settings.
Upvotes: 1