git remote set-url command changes an existing remote repository URL.
git remote set-url command takes two arguments:
- An existing remote name, for example,
- A new URL for the remote, for example:
https://github.com/user/repo2.gitif you're updating to use HTTPS
email@example.com:user/repo2.gitif you're updating to use SSH
git remote -v # View existing remotes # origin https://github.com/user/repo.git (fetch) # origin https://github.com/user/repo.git (push) git remote set-url origin https://github.com/user/repo2.git # Change the 'origin' remote's URL git remote -v # Verify new remote URL # origin https://github.com/user/repo2.git (fetch) # origin https://github.com/user/repo2.git (push)
You may encounter these errors when trying to changing a remote.
This error means that the remote you tried to change doesn't exist:
git remote set-url sofake https://github.com/octocat/Spoon-Knife # fatal: No such remote 'sofake'
Check that you've correctly typed the remote name.
- "Working with Remotes" from the Pro Git book