How to change Remote URL git remote repository

This tutorial explains how to change the remote repository for an existing local repository

This will be used once you migrated the repository from different repositories such as GitHub, GitLab, and bitbucket.

How do I change the URI (URL) for a remote Git repository?

Following are the steps required to change the GitHub remote repository.

One way using the command line

  • Git View the existing remote repository

First, run the git remote -v command on an existing repository

B:\myproject>git remote -v
origin <> (fetch)
origin <> (push)

It points to the GitHub remote repository

  • Change the remote repository Next, change the remote repository to GitLab using the below git remote set-url command

origin is a remote repository

B:\myproject>git remote set-url origin
  • verify remote repository
B:\mygitrepo>git remote -v
origin <> (fetch)
origin <> (push)

Another way using .git/config folder

  • open .git/configin a text editor
[remote "origin"]
url =

Change url to the new remote repository

[remote "origin"]
url =

How to change the URL on a local repository from GitLab to GitHub?

To change the local repository from GitLab to GitHub

  • First get the remote repo using git remote -v command in the Local repository
  • Change from gilab to GitHub using git remote set-url origin newurl command
  • Verify using git remote -v command

This is a similar way to change local repository from GitHub to GitLab