Change a remote's URL
Low risk
What do risk levels mean?
- Read-only
- Inspects state without changing anything.
- Low risk
- Reversible with a routine follow-up command.
- Medium risk
- Changes state; undo path documented.
- Destructive
- Deletes or overwrites; confirmation required.
Points an existing remote at a new URL, for example after a repository is renamed, transferred, or when switching between HTTPS and SSH.
gitremoteurl
Parameters
Name of the remote to update.
New URL for the remote.
Commands
Record the current URL in case it is needed again
git remote get-url originPoint the remote at the new URL
git remote set-url origin <url>Confirm the new URL is reachable and credentials work
git fetch originVerification
git remote -vThe remote lists the new URL for both fetch and push.
Undo
Restore the URL recorded in the first step
git remote set-url origin <previous-url>Pitfalls
- Switching between HTTPS and SSH changes which credentials are used; the fetch step surfaces auth problems immediately.
- Only this clone is affected; other clones and collaborators must update their own remotes.