diff options
author | Soon Van <cog@randomecho.com> | 2012-12-22 07:08:54 +0400 |
---|---|---|
committer | Soon Van <cog@randomecho.com> | 2012-12-22 07:08:54 +0400 |
commit | 34819f50380f3f8bcaadbd5e989165187506ff15 (patch) | |
tree | 78c8faed4c518944603758ee4249d3fa352eb3fb | |
parent | cfb6480f510a19224ed89efbec0207019059ab0e (diff) |
For those times you want to update your remotes
With a note on the slight difference in yelling between
the use of `git remote set-url` and the sheepish,
silent eater of arguments, `git config remote`.
And that you can have a fetch that isn't at the
same house of your push URL.
On the back of #5
-rw-r--r-- | remotes/index.html | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/remotes/index.html b/remotes/index.html index abe0b10..3c91f61 100644 --- a/remotes/index.html +++ b/remotes/index.html @@ -153,6 +153,81 @@ github git@github.com:schacon/hw.git (push) add new remotes and <code>git remote rm</code> to delete existing ones. </p> + <h4> + git remote set-url + <small>update an existing remote URL</small> + </h4> + + <p>Should you ever need to update a remote's URL, you can do so with + the <code>git remote set-url</code> command. + </p> + +<pre> +<b>$ git remote -v</b> +github git@github.com:schacon/hw.git (fetch) +github git@github.com:schacon/hw.git (push) +origin git://github.com/pjhyett/hw.git (fetch) +origin git://github.com/pjhyett/hw.git (push) +<b>$ git remote set-url origin git://github.com/github/git-reference.git</b> +<b>$ git remote -v</b> +github git@github.com:schacon/hw.git (fetch) +github git@github.com:schacon/hw.git (push) +origin git://github.com/github/git-reference.git (fetch) +origin git://github.com/github/git-reference.git (push) +</pre> + + <p>In addition to this, you can set a different push URL when you + include the <code>--push</code> flag. This allows you to fetch from + one repo while pushing to another and yet both use the same remote alias. + </p> + +<pre> +<b>$ git remote -v</b> +github git@github.com:schacon/hw.git (fetch) +github git@github.com:schacon/hw.git (push) +origin git://github.com/github/git-reference.git (fetch) +origin git://github.com/github/git-reference.git (push) +<b>$ git remote set-url --push origin git://github.com/pjhyett/hw.git</b> +<b>$ git remote -v</b> +github git@github.com:schacon/hw.git (fetch) +github git@github.com:schacon/hw.git (push) +origin git://github.com/github/git-reference.git (fetch) +origin git://github.com/pjhyett/hw.git (push) +</pre> + + <p>Internally, the <code>git remote set-url</code> command calls + <code>git config remote</code>, but has the added benefit of reporting + back any errors. <code>git config remote</code> on the other hand, will + silently fail if you mistype an argument or option and not actually set + anything. + </p> + + <p>For example, we'll update the <code>github</code> remote but + instead reference it as <code>guhflub</code> in both invocations. + </p> + +<pre> +<b>$ git remote -v</b> +github git@github.com:schacon/hw.git (fetch) +github git@github.com:schacon/hw.git (push) +origin git://github.com/github/git-reference.git (fetch) +origin git://github.com/github/git-reference.git (push) +<b>$ git config remote.guhflub git://github.com/mojombo/hw.git</b> +<b>$ git remote -v</b> +github git@github.com:schacon/hw.git (fetch) +github git@github.com:schacon/hw.git (push) +origin git://github.com/github/git-reference.git (fetch) +origin git://github.com/github/git-reference.git (push) +<b>$ git remote set-url guhflub git://github.com/mojombo/hw.git</b> +fatal: No such remote 'guhflub' +</pre> + + <p class="nutshell"> + <b>In a nutshell</b>, you can update the locations of your remotes + with <code>git remote set-url</code>. You can also set different push + and fetch URLs under the same remote alias. + </p> + </div> </div> |