如何重命名git存储库? [英] How to rename a git repository?
问题描述
git mv
在存储库中重命名文件或目录。如何重命名git仓库本身?
有很多可能的解释来说明重命名仓库的含义:显示的名称,存储库目录或远程存储库名称。
显示名称
重命名显示的名称(例如,显示为 gitweb
):
- 编辑
.git / description
来包含存储库的名称。 - 保存文件。
- 打开命令提示符(或文件管理器窗口)。
- 转到包含版本库目录的目录(即不要进入版本库目录本身)。 重命名目录(例如,使用
mv
从命令行或F2
热键从GUI)。
- 到REM te主机(例如, https://github.com/User/project )。
- 按照主持人的指示重命名项目(主持人不同,但通常设置是一个很好的起点)。
- 转到您的本地存储库目录(即打开命令提示符并切换到存储库的目录)。
- 确定新的URL(例如
git@github.com :User / project-new.git
) -
使用git设置新的URL:
git remote set-url origin git@github.com:User / project-new.git
- Edit
.git/description
to contain the repository's name. - Save the file.
- 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 (e.g., using
mv
from the command line or theF2
hotkey from a GUI). - Go to the remote host (e.g., 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 (e.g.,
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没有引用包含存储库的目录名称,正如 git clone master child
所使用的那样,所以我们可以简单地重新命名:
$ b
远程仓库
重命名远程仓库如下:
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.
Displayed Name
Rename the displayed name (e.g., shown by gitweb
):
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:
Remote Repository
Rename a remote repository as follows:
这篇关于如何重命名git存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!