Able to push to all git remotes with the one command?

Solution 1:

Create an all remote with several repo URLs to its name:

git remote add all origin-host:path/proj.git
git remote set-url --add all nodester-host:path/proj.git
git remote set-url --add all duostack-host:path/proj.git

Then just git push all --all.


This is how it looks in .git/config:

  [remote "all"]
  url = origin-host:path/proj.git
  url = nodester-host:path/proj.git
  url = duostack-host:path/proj.git

Solution 2:

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) To make a git alias for the command:

git config --global alias.pushall '!git remote | xargs -L1 git push --all'

Running git pushall will now push all branches to all remotes.