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.

Revisions

  1. @bjmiller121 bjmiller121 revised this gist Jul 15, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion multiple-push-urls.md
    Original file line number Diff line number Diff line change
    @@ -18,4 +18,4 @@ origin [email protected]:bjmiller121/second-repo.git (push)

    Now, pushing to this remote will push to both upstreams simultaneiously. Fetch and pull from this remote will still pull from the original repo only.

    **Tip:** If you always want to push to both upstreams simultaneously, you might want to use the `origin` remote. If you only sometimes want to push to both, you might use a remote name like `both`.
    **Tip:** If you always want to push to both upstreams simultaneously, you might want to use the `origin` remote. If you only sometimes want to push to both, you might use a remote name like `both` to indicate that it will push to multiple repos.
  2. @bjmiller121 bjmiller121 revised this gist Jul 15, 2015. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion multiple-push-urls.md
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,15 @@ git remote set-url --add --push [remote] [original repo URL]
    git remote set-url --add --push [remote] [second repo 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.
    Once set up, `git remote -v` should show two (push) URLs and one (fetch) URL. Something like this:

    ```
    $ git remote -v
    origin [email protected]:bjmiller121/original-repo.git (fetch)
    origin [email protected]:bjmiller121/original-repo.git (push)
    origin [email protected]:bjmiller121/second-repo.git (push)
    ```

    Now, pushing to this remote will push to both upstreams simultaneiously. Fetch and pull from this remote will still pull from the original repo only.

    **Tip:** If you always want to push to both upstreams simultaneously, you might want to use the `origin` remote. If you only sometimes want to push to both, you might use a remote name like `both`.
  3. @bjmiller121 bjmiller121 revised this gist Jul 15, 2015. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions multiple-push-urls.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,12 @@
    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:
    Once you have a remote set up for one of your upstreams, run these commands with:

    ```
    git remote set-url --add --push [remote] [remote URL]
    git remote set-url --add --push [remote] [original repo URL]
    git remote set-url --add --push [remote] [second repo 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.

    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.
    **Tip:** If you always want to push to both upstreams simultaneously, you might want to use the `origin` remote. If you only sometimes want to push to both, you might use a remote name like `both`.
  4. @bjmiller121 bjmiller121 created this gist Jul 15, 2015.
    11 changes: 11 additions & 0 deletions multiple-push-urls.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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.