Change Git remote's URL

Git remotes help you manage repositories in a remote server by storing the URL identified with a name. If you migrate the repository to another service, all you need is to change the URL. The default name of cloned repositories remote is origin, and you can have multiple named remotes if you want.

Change Git remote's URL
Photo by Fatos Bytyqi / Unsplash

Git remotes help you manage repositories in a remote server by storing the URL identified with a name. If you migrate the repository to another service, all you need is to change the URL. The default name of cloned repositories remote is origin, and you can have multiple named remotes if you want.

To change the Git remote URL for your local repository, you can use the following command replacing the remote_name and remote_url:

$ git remote set-url <remote_name> <remote_url>

If you want to verify that the remote was updated, you can list them out:

$ git remote -v
> origin	git@gitlab.com:username/repo_name.git (fetch)
> origin	git@gitlab.com:username/repo_name.git (push)

References