Reputation: 48446
In my local repo's .git/config
I have
[remote "public"]
url = https://github.com/rax/somerepo.git
fetch = +refs/heads/*:refs/remotes/public/*
[branch "master"]
remote = public
merge = refs/heads/master
[remote "amazon"]
url = ssh://[email protected]/home/ubuntu/somebarerepo.git
fetch = +refs/heads/*:refs/remotes/amazon/*
[remote "all"]
url = https://github.com/rax/somerepo.git
url = ssh://[email protected]/home/ubuntu/somebarerepo.git
and when I git push all
I successfully push the latest commit to both the amazon
and public
remotes; but the remote branches don't track. For example, if public
is behind when I push, even though the content there is now up to date, the branch is still indicated as behind.
Is there a way to push to more than one remote branch at the same time?
Upvotes: 0
Views: 70
Reputation: 141986
The short answer is that you can do it.
BUT form git version 2.0 the default behavior has changed so you will have to set the 'push.default' to the desired value (matching in your case)
Here is the git v2.0 release notes which explain the change in the way git treat push (simple vs matching). This was updated in git v2.0 to fix the default git push
behavior.
Prior to git v2.0 when you executed git push
it would have pushed all your changed branches (all and not only the current branch).
Git v2.0 Release Notes
Backward compatibility notes
When
git push [$there]
does not say what to push, we have used the traditionalmatching
semantics so far (all your branches were sent to the remote as long as there already are branches of the same name over there). In Git 2.0, the default is now thesimple
semantics, which pushes:
only the current branch to the branch with the same name, and only when the current branch is set to integrate with that remote branch, if you are pushing to the same remote as you fetch from; or
only the current branch to the branch with the same name, if you are pushing to a remote that is not where you usually fetch from.
You can use the configuration variable
push.default
to change this. If you are an old-timer who wants to keep using thematching
semantics, you can set the variable tomatching
, for example. Read the documentation for other possibilities.strong text
Upvotes: 1