Home / How to change the remote url for your local git repository

How to change the remote url for your local git repository

If you’ve moved a git repository from one git hosting service to another, transferred from one account to another at the same service (here’s how to transfer between accounts at Bitbucket) or moved your own repository servers around the place, you’ll need to change the remote url for you local repository to be able to continue pushing and pulling changes, etc.

Check the existing remotes

Use this command to check what you have configured as the current remote:

git remote -v

If the git repository is at e.g. Bitbucket, the login name MyUsername and the repository coolproject, then running the above command would output something like this:

origin	git@bitbucket.MyUsername/coolproject.git (fetch)
origin	git@bitbucket.org:MyUsername/coolproject.git (push)

Change the remote url

To change your local repository’s origin to e.g. another accout within Bitbucket (YourUsername), use the set-url command like so:

git remote set-url origin git@bitbucket.org:YourUsername/coolproject.git

Done! You might want to run "git remote -v" again to check it’s all looking good.