How do I rename a repository on GitHub? How do I rename a repository on GitHub? git git

How do I rename a repository on GitHub?


If you are the only person working on the project, it's not a big problem, because you only have to do #2.

Let's say your username is someuser and your project is called someproject.

Then your project's URL will be1

git@github.com:someuser/someproject.git

If you rename your project, it will change the someproject part of the URL, e.g.

git@github.com:someuser/newprojectname.git

(see footnote if your URL does not look like this).

Your working copy of Git uses this URL when you do a push or pull.

So after you rename your project, you will have to tell your working copy the new URL.

You can do that in two steps:

Firstly, cd to your local Git directory, and find out what remote name(s) refer to that URL:

$ git remote -vorigin  git@github.com:someuser/someproject.git

Then, set the new URL

$ git remote set-url origin git@github.com:someuser/newprojectname.git

Or in older versions of Git, you might need:

$ git remote rm origin$ git remote add origin git@github.com:someuser/newprojectname.git

(origin is the most common remote name, but it might be called something else.)

But if there are lots of people who are working on your project, they will all need to do the above steps, and maybe you don't even know how to contact them all to tell them. That's what #1 is about.

Further reading:

Footnotes:

1 The exact format of your URL depends on which protocol you are using, e.g.


Note that since May 2013 ("Repository redirects are here!"), you can rename your GitHub repo without breaking any links:

We're happy to announce that starting today, we'll automatically redirect all requests for previous repository locations to their new home in these circumstances. There's nothing special you have to do. Just rename away and we'll take care of the rest.

As a special bonus, we'll also be servicing all Git clone, fetch, and push requests from previous repository locations.

That means you don't even have to git remote set-url (change the url of your remote GitHub repo) on your local cloned repo!
Although Gabriel notes in the comments that the official GitHub help page strongly recommends that you do so:

to reduce confusion, we strongly recommend updating any existing local clones to point to the new repository URL. You can do this by using git remote on the command line:

git remote set-url origin new_url

Beware though:

GitHub Pages sites are not automatically redirected when their repositories are renamed at this time.
Renaming a Pages repository will continue to break any existing links to content hosted on the github.io domain or custom domains.

Plus, the user still owns the namespace: if he/she creates a new repo using the old name of the renamed repo, that redirection (for said renamed repo) will stop working.


I rename my own just by simply :

  1. going to github.com on my repository
  2. Open Settings Tab
  3. The first setting you can see is the "Repository Name"
  4. Change the actual one and put the new name you want to give to your repository
  5. Click on "Rename" button

After this step, GitHub will make sure that, your online repository matches your local folder name.At this step your problem is solved, unless you also want to rename your local folder. Then do it manually and just use the Github client for windows to refind again your repository into your hard drive, and Github will match it again.That's all!Very simple.