如何重命名Git存储库? [英] How do I rename a Git repository?

查看:115
本文介绍了如何重命名Git存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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):

  1. 编辑.git/description以包含存储库的名称.
  2. 保存文件.
  1. Edit .git/description to contain the repository's name.
  2. 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:

  1. 打开命令提示符(或文件管理器窗口).
  2. 转到包含存储库目录的目录(即,不要进入存储库目录本身).
  3. 重命名目录(例如,使用命令行中的mv或GUI中的 F2 热键).
  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 (for example, using mv from the command line or the F2 hotkey from a GUI).

远程存储库

重命名远程存储库,如下所示:

Remote Repository

Rename a remote repository as follows:

  1. 转到远程主机(例如, https://github.com/User/project ).
  2. 按照主持人的指示对项目进行重命名(各个主持人之间会有所不同,但是通常设置是一个很好的起点).
  3. 转到本地存储库目录(即,打开命令提示符并更改为存储库目录).
  4. 确定新的URL(例如,git@github.com:User/project-new.git)
  5. 使用Git设置新网址:

  1. Go to the remote host (for example, 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 (for example, 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

这篇关于如何重命名Git存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆