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. +

+