@@ -153,6 +153,81 @@ <h4>
153153 add new remotes and < code > git remote rm</ code > to delete existing ones.
154154 </ p >
155155
156+ < h4 >
157+ git remote set-url
158+ < small > update an existing remote URL</ small >
159+ </ h4 >
160+
161+ < p > Should you ever need to update a remote's URL, you can do so with
162+ the < code > git remote set-url</ code > command.
163+ </ p >
164+
165+ < pre >
166+ < b > $ git remote -v</ b >
167+ github git@github.com:schacon/hw.git (fetch)
168+ github git@github.com:schacon/hw.git (push)
169+ origin git://github.com/pjhyett/hw.git (fetch)
170+ origin git://github.com/pjhyett/hw.git (push)
171+ < b > $ git remote set-url origin git://github.com/github/git-reference.git</ b >
172+ < b > $ git remote -v</ b >
173+ github git@github.com:schacon/hw.git (fetch)
174+ github git@github.com:schacon/hw.git (push)
175+ origin git://github.com/github/git-reference.git (fetch)
176+ origin git://github.com/github/git-reference.git (push)
177+ </ pre >
178+
179+ < p > In addition to this, you can set a different push URL when you
180+ include the < code > --push</ code > flag. This allows you to fetch from
181+ one repo while pushing to another and yet both use the same remote alias.
182+ </ p >
183+
184+ < pre >
185+ < b > $ git remote -v</ b >
186+ github git@github.com:schacon/hw.git (fetch)
187+ github git@github.com:schacon/hw.git (push)
188+ origin git://github.com/github/git-reference.git (fetch)
189+ origin git://github.com/github/git-reference.git (push)
190+ < b > $ git remote set-url --push origin git://github.com/pjhyett/hw.git</ b >
191+ < b > $ git remote -v</ b >
192+ github git@github.com:schacon/hw.git (fetch)
193+ github git@github.com:schacon/hw.git (push)
194+ origin git://github.com/github/git-reference.git (fetch)
195+ origin git://github.com/pjhyett/hw.git (push)
196+ </ pre >
197+
198+ < p > Internally, the < code > git remote set-url</ code > command calls
199+ < code > git config remote</ code > , but has the added benefit of reporting
200+ back any errors. < code > git config remote</ code > on the other hand, will
201+ silently fail if you mistype an argument or option and not actually set
202+ anything.
203+ </ p >
204+
205+ < p > For example, we'll update the < code > github</ code > remote but
206+ instead reference it as < code > guhflub</ code > in both invocations.
207+ </ p >
208+
209+ < pre >
210+ < b > $ git remote -v</ b >
211+ github git@github.com:schacon/hw.git (fetch)
212+ github git@github.com:schacon/hw.git (push)
213+ origin git://github.com/github/git-reference.git (fetch)
214+ origin git://github.com/github/git-reference.git (push)
215+ < b > $ git config remote.guhflub git://github.com/mojombo/hw.git</ b >
216+ < b > $ git remote -v</ b >
217+ github git@github.com:schacon/hw.git (fetch)
218+ github git@github.com:schacon/hw.git (push)
219+ origin git://github.com/github/git-reference.git (fetch)
220+ origin git://github.com/github/git-reference.git (push)
221+ < b > $ git remote set-url guhflub git://github.com/mojombo/hw.git</ b >
222+ fatal: No such remote 'guhflub'
223+ </ pre >
224+
225+ < p class ="nutshell ">
226+ < b > In a nutshell</ b > , you can update the locations of your remotes
227+ with < code > git remote set-url</ code > . You can also set different push
228+ and fetch URLs under the same remote alias.
229+ </ p >
230+
156231 </ div >
157232</ div >
158233
0 commit comments