Little Git Tricks: Change the URL of Your Remote Repository

Sometimes your Git repositories move to another location. You certainly can throw your local copy away and clone it from the new location. However, there is a simpler way that only requires you to update the remote URL and you can continue with your local copy – including all your unpushed changes.

Before you make any changes, you should check what the current URL of your remote repository is. Open a Command Prompt in your Git repository and enter this command:

Please double-check that this is the repository and the origin location you want to modify. You can without any problems merge different repositories together by using the wrong URL.

If everything looks OK, you can set a new URL for your origin repository:

That’s it. To make sure everything looks as expected you should check once more the URLs of your remote repository:

 

Conclusion

Updating a URL for your remote repository is not much work. If you have multiple remote repositories you need to be a bit more careful. But even then, it should be a lot faster than to clone your repository.

1 thought on “Little Git Tricks: Change the URL of Your Remote Repository”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.