How to Rename Github Repository URL Remotely and Locally

Sometimes you may need to rename your Github Repository URL for various reasons. We are not going to discuss those various reasons here of course, but in this simple tutorial I will show you how you can rename and update your github repo url remotely and locally.

By renaming url here I only mean by renaming or moving the Github repository URL. If you want to learn more about renaming a Gihub repository in detail you would want to check this stackoverflow question.

Let’s continue with renaming repository url. The current url of my example Github repo is https://github.com/User/foo.git and I am going to change it to https://github.com/User/foo.git.

Step 1: Rename Github repository URL on github.com

The first step is to rename repository URL on github.com website. Login to github.com and go to repository page. On the repository page click the settings icon as shown in the figure below.

Rename it to a different name. I renamed it to bar. (figure below)

Rename Github Repository URL

 

Step 2: Rename Github repository URL locally

On your local machine cd to the current working directory of your git repository to to rename repository URL locally.

Then check the currently used Github repository full url by typing

git config --get remote.origin.url

It should display your currently used github repository url

https://github.com/User/foo.git

Let’s change it to reflect new url. Since I had used HTTPS url to clone I will use HTTPS url. To find your HTTP URL you can check the github website’s Code section.(figure below)

Or to find the SSH URL use SSH tab:(figure below)

Rename Github Repository URL

Copy the url as shown in one of the example images above. Then go back to your current repository directory locally and run:

git remote set-url origin https://github.com/User/bar.git

Confirm it by typing

git config --get remote.origin.url

It should display your new Github repository URL

https://github.com/User/bar.git

That should be it.

Conclusion

Following two steps as shown above you should be able to move or rename your github repo url. In first step you rename the name of your Github repository which eventually renames your Github repo url. In the second step you run git remote set-url command to update the repository url locally.

Leave a Reply