Git remote – pushing to multiple repositories at once

If you have set up multiple repositories (see my previous post; Git remote basic) you can use the following technique to push the same code to all the repositories without having to push multiple times.

Using the following commands you are able to add two PUSH urls for “origin”.
NOTE: This will also override the default URL you already have set up for pushes. So you will need to add your default PUSH url followed by your new url.

$  git remote set-url --add --push origin [defaulturl]
$  git remote set-url --add --push origin [urlToSecondRepo]

Now when you do a push to “origin”, it will push to both the repositories.

You can view the remotes you have set up by doing the following:

$  git remote -v

You can delete the new PUSH url by doing the following:

$  git remote set-url --delete --push [remoteName] [url]

Leave a Reply