How To Change Git Remote's URL

How To Change Git Remote URL?


Git remote is a pointer that refers to another copy of the repository that is usually hosted on a remote server.
In some situations, like when the remote repository is migrated to another host, you need to change the remote’s URL.

This guide explains how to change the URL of a Git remote.

Changing a Git Remote URL

To change the URL of a remote:

Step 1: Change to the directory where the repository is located:
cd /path/to/repository
Step 2: Run git remote to list the existing remotes and see their names and URLs:
git remote -v
The output will look something like this:
origin (fetch)
origin (push)
Step 3: Use the git remote set-url command followed by the remote name, and the remote’s URL:
git remote set-url
Note: The remote’s URL can start with HTTPS or SSH, depending on the protocol you’re using. If no protocol is specified, it defaults to SSH. The URL can be found on the repository page of your Git hosting service.

For example, to change the URL of the origin to you would type:
git remote set-url origin
Verify that the remote’s URL was successfully changed by listing the remote connections:
git remote -v
The output should look like this:
origin (fetch)
origin (push)
That’s it. You have successfully changed the URL of the remote.


The git remote set-url command actually is updating the repository .git/config file with a new URL to the remote repository.

Have more questions? Please email us at
Also, let us know if the article is helpful!

    • Related Articles

    • Simple steps to synchronise a Remote Fork in a Git repository

      Introduction When you collaborate in any upstream project (like an open-source project) it is likely to be asked to make a fork of the main repository. A fork is a copy of the project in your Git account. This duplicate allows you to freely ...
    • How to duplicate a Git repository? Repository mirroring simplified.

      To duplicate a repository without forking it, you can run a special clone command, then mirror-push to the new repository. Before you can duplicate a repository and push to your new copy, or mirror, of the repository, you must create the new ...
    • PWSLab Git Workshop - Useful commands and concepts

      Agenda A brief history of Git. PWSLab walkthrough. Configure your environment. Workshop. Git Introduction Visit: Distributed version control. It does not rely on a connection to a central server. Many copies of the complete ...
    • Mirroring PWSLab Repositories to GitHub, Bitbucket and GitLab or any Git repositories

      Introduction Repository mirroring allows for mirroring of repositories to external sources. It can be used to mirror branches, tags, and commits between repositories. A repository mirror at PWSLab will be updated automatically. You can also manually ...
    • How to apply Git Patches?

      Patch is a text file, whose contents are similar to Git diff, but along with code, it also has metadata about commits; e.g., commit ID, date, commit message, etc. We can create a patch from commits and other people can apply them to their repository. ...