63

Possible Duplicate:
Change repo name in github

I got some github repos that i now need to rename, but i can't anywhere find a solution for this except deleting the repo and setting up a new one. I can't delete the repos, because there are a lot of links pointing to the current repos, which i don't want to loose. Anyone any idea on how to do this? (I already read a lot of the google results and searched the github support).

Community
  • 1
  • 1
kaiser
  • 21,817
  • 17
  • 90
  • 110

3 Answers3

95

I have changed the name of repositories before, and I'm doing it again right now ;-)

Edit the name using the built-in feature under the "Settings" tab at the top of your GitHub repository page. Then go to your local repository and rename the remote. Like this:

  1. First remove it:

    git remote rm origin
    
  2. then add back the new name

    git remote add origin git@github.com:"yourname"/"projectname".git
    

If you have recent enough git version you should use set-url command:

    git remote set-url origin git@github.com:"yourname"/"projectname".git

Now it should be good to go.

Lesmana
  • 25,663
  • 9
  • 82
  • 87
carolineggordon
  • 1,066
  • 1
  • 7
  • 6
27

Yes you can, see here:

Rename github repo

If I understand you correctly you want to rename your git repository eg xyz.git to xyz1.git and then have all the git repositories that link to that repo link to the new name automatically?

As far as I know this isn't possible. Each repository is self contained and keeps a list of locations it links to. If one of those locations changes its name the link would be broken. Each repository that references the changed name would need to update its link.

But then, the same would happen if you deleted a repository and recreated it under a new name....

Just realised you were specifically talking about GitHub and not git in general, sorry - should learn to read the entire question like my school teachers said. The answer still stands, with the addition that you can change the name in GitHub from the Admin page.

brandonscript
  • 68,675
  • 32
  • 163
  • 220
Russell Troywest
  • 8,635
  • 3
  • 35
  • 40
  • 2
    Renaming via the "admin" page... omg. Thanks a lot! Btw: The mentioned links are from outside spread around blogs, forums, SE, etc. – kaiser Apr 16 '11 at 13:47
  • Nice. Just used this info to rename a repo from the github admin page of my repo. The cool thing is that GitHub for Windows automatically updated my local repo with the new name. Didn't even have to refresh. – Giscard Biamby Oct 03 '12 at 19:29
3

You also do it via v3 of their API. See here: How do I rename a GitHub repository via their API?

Community
  • 1
  • 1
braitsch
  • 14,906
  • 5
  • 42
  • 37
  • if had tracking enabled for the repository, you probably want to track it again: `git branch --set-upstream master origin/master` – arturhoo Apr 27 '12 at 02:56