From 34819f50380f3f8bcaadbd5e989165187506ff15 Mon Sep 17 00:00:00 2001 From: Soon Van Date: Fri, 21 Dec 2012 22:08:54 -0500 Subject: [PATCH] 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 --- remotes/index.html | 75 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) 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 git remote rm to delete existing ones.

+

+ git remote set-url + update an existing remote URL +

+ +

Should you ever need to update a remote's URL, you can do so with + the git remote set-url command. +

+ +
+$ git remote -v
+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)
+$ git remote set-url origin git://github.com/github/git-reference.git
+$ git remote -v
+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)
+
+ +

In addition to this, you can set a different push URL when you + include the --push flag. This allows you to fetch from + one repo while pushing to another and yet both use the same remote alias. +

+ +
+$ git remote -v
+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)
+$ git remote set-url --push origin git://github.com/pjhyett/hw.git
+$ git remote -v
+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)
+
+ +

Internally, the git remote set-url command calls + git config remote, but has the added benefit of reporting + back any errors. git config remote on the other hand, will + silently fail if you mistype an argument or option and not actually set + anything. +

+ +

For example, we'll update the github remote but + instead reference it as guhflub in both invocations. +

+ +
+$ git remote -v
+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)
+$ git config remote.guhflub git://github.com/mojombo/hw.git
+$ git remote -v
+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)
+$ git remote set-url guhflub git://github.com/mojombo/hw.git
+fatal: No such remote 'guhflub'
+
+ +

+ In a nutshell, you can update the locations of your remotes + with git remote set-url. You can also set different push + and fetch URLs under the same remote alias. +

+