Posted By: Anonymous
git mv renames a file or directory in a repository. How do I rename the Git repository itself?
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.
Rename the displayed name (for example, shown by
.git/descriptionto contain the repository’s name.
- Save the file.
Git does not reference the name of the directory containing the repository, as used by
git clone master child, so we can simply rename it:
- Open a command prompt (or file manager window).
- Change to the directory that contains the repository directory (i.e., do not go into the repository directory itself).
- Rename the directory (for example, using
mvfrom the command line or the F2 hotkey from a GUI).
Rename a remote repository as follows:
- Go to the remote host (for example, https://github.com/User/project).
- Follow the host’s instructions to rename the project (will differ from host to host, but usually Settings is a good starting point).
- Go to your local repository directory (i.e., open a command prompt and change to the repository’s directory).
- Determine the new URL (for example,
Set the new URL using Git:
git remote set-url origin [email protected]:User/project-new.git