Skip to content

Instantly share code, notes, and snippets.

@changebio
Forked from bjmiller121/multiple-push-urls.md
Created May 2, 2018 13:24
Show Gist options
  • Select an option

  • Save changebio/a5c6ff913f9e8246a2e35601c4dfb3b4 to your computer and use it in GitHub Desktop.

Select an option

Save changebio/a5c6ff913f9e8246a2e35601c4dfb3b4 to your computer and use it in GitHub Desktop.
Add multiple push URLs to a single git remote

Sometimes you need to keep two upstreams in sync with eachother. For example, you might need to both push to your testing environment and your GitHub repo at the same time. In order to do this simultaneously in one git command, here's a little trick to add multiple push URLs to a single remote.

Once you have a remote set up for one of your upstreams, run this command with the same remote name and the URL of the second remote:

git remote set-url --add --push [remote] [remote URL]

Note: The first time you run this, it might overwrite the default push URL so you'll have to re-run the same command again with the original URL remote URL.

Once set up, git remote -v should show two (push) URLs and one (fetch) URL. Now, pushing to this remote will push to both upstreams simultaneiously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment