如何重命名Git存储库? [英] How do I rename a Git repository?
问题描述
git mv
重命名存储库中的文件或目录.如何重命名Git存储库本身?
git mv
renames a file or directory in a repository. How do I rename the Git repository itself?
推荐答案
重命名Git存储库的含义有多种可能的解释:显示的名称,存储库目录或远程存储库名称.每个步骤都需要不同的步骤来重命名.
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.
重命名显示的名称(例如,由gitweb
显示):
Rename the displayed name (for example, shown by gitweb
):
- 编辑
.git/description
以包含存储库的名称. - 保存文件.
- Edit
.git/description
to contain the repository's name. - Save the file.
存储库目录
Git不引用git clone master child
所使用的包含存储库的目录的名称,因此我们可以简单地重命名它:
Repository Directory
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:
- 打开命令提示符(或文件管理器窗口).
- 转到包含存储库目录的目录(即,不要进入存储库目录本身).
- 重命名目录(例如,使用命令行中的
mv
或GUI中的 F2 热键).
- 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
mv
from the command line or the F2 hotkey from a GUI).
远程存储库
重命名远程存储库,如下所示:
Remote Repository
Rename a remote repository as follows:
- 转到远程主机(例如, https://github.com/User/project ).
- 按照主持人的指示对项目进行重命名(各个主持人之间会有所不同,但是通常设置是一个很好的起点).
- 转到本地存储库目录(即,打开命令提示符并更改为存储库目录).
- 确定新的URL(例如,
git@github.com:User/project-new.git
) -
使用Git设置新网址:
- 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,
git@github.com:User/project-new.git
) Set the new URL using Git:
git remote set-url origin git@github.com:User/project-new.git
这篇关于如何重命名Git存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!