Search code examples
gitgit-remote

Difference between git remote set-url and remote remove then add?


Is there any difference between doing git remote set-url foo bar and:

git remote remove foo
git remote add foo bar

Assume foo is a single-URL remote.


Solution

  • git remote remove also removes remote-tracking branches and git remote add doesn't restore them. You need to git fetch to fetch remote branches.

    git remote set-url changes the URL without affecting remote-tracking branches.