Change the URL of a remote repository

The git remote set-url command changes an existing remote repository URL.

This command takes two arguments:

  1. An existing remote name. For example, origin or upstream are two common choices.

  2. A new URL for the remote. For example,

So to change the URL of a remote repository you would do something like this:

  1. View the existing remote repository:

git remote -v

  1. Change the URL of the remote repository:

git remote set-url origin

  1. And you may verify the new remote repository by doing:

git remote -v

Git Remote

The git remote command allows you to manage your Git remote repositories. Remote repositories are references to other Git repositories that operate on the same codebase.

You can pull from and push to remote repositories.

You can push or pull to either an HTTPS URL, such as , or an SSH URL, like .

Don’t worry, every time you push something, you don’t need to type the entire URL. Git associates a remote URL with a name, and the name most people use is origin .

List all configured remote repositories

git remote -v

This command lists all remote repositories alongside their location.

Remote repositories are referred to by name. As noted above, the main repository for a project is usually called origin .

When you you use git clone to obtain a copy of a repository, Git sets up the original location as the origin remote repository.

Add a remote repository

To add a remote repository to your project, you would run the following command:


The REMOTE-URL can be either HTTPS or SSH. You can find the URL on GitHub by clicking the “Clone or download” dropdown in your repository.

For example, if you want to add a remote repository and call it example , you would run:

git remote add example

Update a remote URL

If the URL of a remote repository changes, you can update it with the following command, where example is the name of the remote:

git remote set-url example

Deleting Remotes

Deleting remotes is done like so:

git remote rm REMOTE-NAME

You can confirm the remote is gone by viewing the list of your existing remotes:

git remote -v
1 Like