Multiple git remotes
When working with multiple remotes in git you sometimes want the possibility of pushing to all your remotes in one go. This can be achieved as explained beautifully in the Stack overflow question - https://stackoverflow.com/questions/5785549/able-to-push-to-all-git-remotes-with-the-one-command however it is not listed how to do it for specific branch although the solution is "given".
So to make it completed (and for myself to remember at a later stage) I have also added the additional bonus step if you want to push only 1 branch to all remotes instead of all branches to all remotes.
To push all branches to all remotes:
git remote | xargs -L1 git push --all
Or if you want to push a specific branch to all remotes:
Replace master
with the branch you want to push.
git remote | xargs -L1 -I R git push R master
(Bonus) Git alias for the command all branches, all remotes:
git config --global alias.pushall '!git remote | xargs -L1 git push --all'
Running git pushall
will now push all branches to all remotes.
(Bonus2) Git alias for the command of one branch, all remotes:
git config --global alias.pushbranch '!git remote | xargs -L1 -I R git push R'
Running git pushbranch <your branch>
will now push specified branch to all your remotes.