如何重命名git存储库? [英] How to rename a git repository?

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

问题描述

git mv 在存储库中重命名文件或目录。如何重命名git仓库本身?

解决方案

有很多可能的解释来说明重命名仓库的含义:显示的名称,存储库目录或远程存储库名称。



显示名称



重命名显示的名称(例如,显示为 gitweb ):


  1. 编辑 .git / description 来包含存储库的名称。

  2. 保存文件。


  3. Git没有引用包含存储库的目录名称,正如 git clone master child 所使用的那样,所以我们可以简单地重新命名:
    $ b


    1. 打开命令提示符(或文件管理器窗口)。

    2. 转到包含版本库目录的目录(即不要进入版本库目录本身)。 重命名目录(例如,使用 mv 从命令行或 F2 热键从GUI)。



    远程仓库



    重命名远程仓库如下:


    1. 到REM te主机(例如, https://github.com/User/project )。

    2. 按照主持人的指示重命名项目(主持人不同,但通常设置是一个很好的起点)。

    3. 转到您的本地存储库目录(即打开命令提示符并切换到存储库的目录)。
    4. 确定新的URL(例如 git@github.com :User / project-new.git

    5. 使用git设置新的URL:

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



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

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

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

    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
      

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

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