Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to rename remotes in git?

Tags:

git

git-remote

I have 2 remotes - origin and remote2 one and I want to rename remote2 to origin and origin to source. Is it safe to do so? If yes, how do I do it?

Edit: By safe I mean that if some branch is tracked from "origin", will it continue to be track from "source" after rename. Also I wish I new what else could go wrong :)

like image 671
Artem Avatar asked Feb 03 '14 20:02

Artem


1 Answers

I believe it is safe, yes, unless you have scripts referencing the remote by name for instance (in which case these will still use the old remote name).

The command is:

git remote rename <old> <new>

So if you have something tracked from foo, then rename foo to bar, it will now be tracked from bar. To check, use:

git remote -v show
git branch -a -v

before and after.

like image 181
abligh Avatar answered Oct 08 '22 20:10

abligh