How do I rename a repository on GitHub?

前端 未结 12 1515
无人及你
无人及你 2020-11-28 17:13

I wanted to rename one of my repositories on GitHub, but I got scared when a big red warning said:

  1. We will not set up any redirects from the o
相关标签:
12条回答
  • 2020-11-28 17:52
    • Navigate to your repository path.
    • Click on setting button which is there in right panne.
    • Replace old repository name to new name.
    • Click on Rename button
    0 讨论(0)
  • 2020-11-28 17:54

    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.

    0 讨论(0)
  • 2020-11-28 17:58

    I have tried to rename the repository on the web page:

    1. Click on the top of the right pages that it's your avatar.
    2. you can look at the icon of setting, click it and then you can find the Repositories under the Personal setting.
    3. click the Repositories and enter your directories of Repositories, choose the Repository that you want to rename.
    4. Then you will enter the chosen Repository and you will find the icon of setting is added to the top line, just click it and enter the new name then click Rename.

    Done, so easy.

    0 讨论(0)
  • 2020-11-28 17:59

    Simple solution:

    1) Open your project url: https://github.com/someuser/project-name
    2) in the top, aside of the project name, click EDIT

    0 讨论(0)
  • 2020-11-28 18:00

    I see a lot of positive feedback to responses I don't find accurate/complete at all.

    There are two things to have in mind:

    • Remote repository
    • Local copy of the repository

    If you haven't cloned your repo in your machine yet, you just need to rename the Github repository and then proceed to clone the repo so you can have a local copy. In order to rename the Github repo, you just need to:

    1. Go to the repository site (i.e https://github.com/userX/repositoryZ).
    2. In the navigation bar, you will see a tab named "Settings". Click on it.
    3. Just edit the current repository name with the desired one and press "Rename".
    4. Clone the repository as usual (i.e git clone https://github.com/userX/repositoryU).

    If you already have a local copy of the project, apart from following the steps above, you need to make sure your local repository (root folder) is renamed properly and it's pointing to the right remote url :) link. In order to achieve that, do the following:

    1. You might want to use the new given name for your repo. To do so, rename the local folder either by using the OS GUI(Finder, Windows Explorer, etc.) or console:

    mv -R current-repo-name new-repo-name

    1. Change the remote url. From the root of the folder, use the following:

    $ git remote set-url origin https://github.com/userX/repositoryU

    or

    $ git remote set-url origin git@github.com:userX/repositoryU.git

    The second step is not mandatory, though. Github announced a while ago that they would redirect all requests from previous repository urls to the assigned ones. That means you don't need to use $ git remote set-url ..., but they still encourage you to do so to avoid confusion.

    Hope it helped. If you have any questions or the post is not clear enough, let me know.

    0 讨论(0)
  • 2020-11-28 18:02

    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

    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.

    0 讨论(0)
提交回复
热议问题