Is it safe to rename remotes in git?

git, git-remote

Solution

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.

Problem

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 :)

Original source