Yantao Xie Yantao Xie - 1 year ago 128
Git Question

How to rename a git repository?

git mv
will rename a file or directory in a repository. How do I rename the git repository itself?

Answer Source

There are various possible interpretations of what is meant by renaming a git repository: the displayed name, the repository directory, or the remote repository name. Each requires different steps to rename.

Displayed Name

Rename the displayed name (e.g., shown by gitweb):

  1. Edit .git/description to contain the repository's name.
  2. Save the file.

Repository Directory

Rename the directory containing the repository, as used by git clone master child:

  1. Open a command prompt (or file manager window).
  2. Change to the directory that contains the repository directory (i.e., do not go into the repository directory itself).
  3. Rename the directory (e.g., using mv from the command line or the F2 hotkey from a GUI).

Git does not reference this directory name.

Remote Repository

Rename a remote repository as follows:

  1. Go to the remote host (e.g., https://github.com/User/project).
  2. Follow the host's instructions to rename the project (will differ from host to host, but usually Settings is a good starting point).
  3. Go to your local repository directory (i.e., open a command prompt and change to the repository's directory).
  4. Determine the new URL (e.g., git@github.com:User/project-new.git)
  5. Set the new URL using git:

git remote set-url origin git@github.com:User/project-new.git

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download