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

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 [email protected]: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.

Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to github

Does the target directory for a git clone have to match the repo name? Issue in installing php7.2-mcrypt How can I switch to another branch in git? How to draw checkbox or tick mark in GitHub Markdown table? How to add a new project to Github using VS Code git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 How to add empty spaces into MD markdown readme on GitHub? key_load_public: invalid format git - remote add origin vs remote set-url origin Cloning specific branch

Examples related to repository

Kubernetes Pod fails with CrashLoopBackOff Project vs Repository in GitHub How to manually deploy artifacts in Nexus Repository Manager OSS 3 How to return a custom object from a Spring Data JPA GROUP BY query How do I force Maven to use my local repository rather than going out to remote repos to retrieve artifacts? How do I rename both a Git local and remote branch name? Can't Autowire @Repository annotated interface in Spring Boot How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning? git repo says it's up-to-date after pull but files are not updated Transfer git repositories from GitLab to GitHub - can we, how to and pitfalls (if any)?