razzi.abuissa.net

Pushing to multiple git remotes

2025-12-26

Let’s say you have multiple remotes of a git repository on different git forges.

You can add a remote called “all” that when you push to it (git push all) it will push to all remotes.


Here’s the starting point, a git repository with 2 remotes:

$ git remote -v
origin	https://codeberg.org/razzi/fish-functions.git (fetch)
origin	https://codeberg.org/razzi/fish-functions.git (push)
github	git@github.com:razzius/fish-functions.git (fetch)
github	git@github.com:razzius/fish-functions.git (push)

Add a duplicate of one of the remotes as all:

$ git remote add all https://codeberg.org/razzi/fish-functions.git
$ git remote -v
all	https://codeberg.org/razzi/fish-functions.git (fetch)
all	https://codeberg.org/razzi/fish-functions.git (push)
origin	https://codeberg.org/razzi/fish-functions.git (fetch)
origin	https://codeberg.org/razzi/fish-functions.git (push)
github	git@github.com:razzius/fish-functions.git (fetch)
github	git@github.com:razzius/fish-functions.git (push)

Add the other remote as another push url of all (notice the 2 push urls):

$ git remote set-url --add --push all git@github.com:razzius/fish-functions.git
$ git remote -v
all	https://codeberg.org/razzi/fish-functions.git (fetch)
all	git@github.com:razzius/fish-functions.git (push)
all	https://codeberg.org/razzi/fish-functions.git (push)
[...]

Now when you run git push all it will push to all remotes:

$ git push all
Everything up-to-date
Everything up-to-date

More info: https://stackoverflow.com/a/14290145/1636613