Skip to main content

How to push to two github remotes at once

For the purposes of backup and resilience, it may be useful to maintain two identical git remotes for a repo. Maybe one is on github, and another one is on a machine on another cloud. Then, you may want to automate pushing every change to the two repos at once.

git remote set-url       --push origin git@github.com:<username>/<reponame>.git
git remote set-url --add --push origin git@git:/home/git/repos/
git push origin

Push to multiple remotes. Add the hosted Git server as a remote: 

git remote add git git@git:/home/git/repos/jamserver.git

Set multiple push URLs for Github and the server:

git remote set-url --push origin git@github.com:<username>/<reponame>.git 
git remote set-url --add --push origin git@git:/home/git/repos/<reponame>.git

Verify push URLs: 

git remote get-url --all --push origin

Push to both remotes: 

git push origin

or to a specific remote: 

git push git

That's it!

.^.

marlyn mondoe beautiful

https://cityad-all-prod.s3.amazonaws.com/public/2025-12/600x450%20marlyn-monroe.jpg
Please login to post comments: _TODO