Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Change Git Remote URL
The git remote set-url
command changes an existing remote repository URL.
The git remote set-url
command takes two arguments:
An existing remote name. For example, origin
or upstream
are two common choices.
A new URL for the remote. For example:
If you’re updating to use HTTPS, your URL might look like:
https://github.com/OWNER/REPOSITORY.git
If you’re updating to use SSH, your URL might look like:
git@github.com:OWNER/REPOSITORY.git
Switching remote URL
Open Git Bash.
Change the current working directory to your local project.
List your existing remotes in order to get the name of the remote you want to change.
# SSH
$ git remote -v
> origin git@github.com:OWNER/REPOSITORY.git (fetch)
> origin git@github.com:OWNER/REPOSITORY.git (push)
# HTTPS
$ git remote -v
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push)
- Change your remote’s URL with the git remote set-url command.
# To HTTPS
git remote set-url origin https://github.com/OWNER/REPOSITORY.git
# To SSH
git remote set-url origin git@github.com:OWNER/REPOSITORY.git
- Verify that the remote URL has changed.
# HTTPS
$ git remote -v
# Verify new remote URL
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push)
# SSH
$ git remote -v
# Verify new remote URL
> origin git@github.com:OWNER/REPOSITORY.git (fetch)
> origin git@github.com:OWNER/REPOSITORY.git (push)
Notice: If change remote url from SSH to HTTPS, when you next time do git fetch
, git pull
, or git push
to the remote repository, you’ll be asked for your username and password. When Git prompts you for your password, enter your personal access token.