Git mv重命名存储库中的文件或目录。如何重命名Git存储库本身?


当前回答

重命名你的GitHub帐户的任何存储库:

转到要重命名的特定存储库 导航到设置选项卡 在存储库名称部分中,键入想要放置的新名称并单击Rename

其他回答

重命名你的GitHub帐户的任何存储库:

转到要重命名的特定存储库 导航到设置选项卡 在存储库名称部分中,键入想要放置的新名称并单击Rename

如果你在Eclipse中并且已经安装了Egit,那么你可以重命名包含项目的存储库,方法如下:

1)在Eclipse中:关闭存储库中的所有项目。

2)在文件系统中:找到存储库所在的目录/文件夹。

3)在文件系统中:重命名存储库所在的目录/文件夹。

4)在文件系统中:打开包含存储库的目录/文件夹,重命名任何您打算重命名的项目的项目目录/文件夹,使其与项目的新名称匹配。(这不是必需的,但它使Eclipse中的项目名称与存储库中的项目目录/文件夹保持一致。)

5)在Eclipse中:删除存储库中的所有项目,但确保不要勾选“从文件系统中删除内容”复选框。(该项目应该不再包含文件系统内容的正确位置,因此数据在任何情况下都不能被删除,但安全总比遗憾好。)

6)在Eclipse中:从菜单中选择文件|Import…选择。

7)在Eclipse中:在对话框中打开“Git”文件夹,选择“Projects from Git”,然后单击“Next”。

8)在Eclipse中:在对话框中选择“Local”,然后单击“Next”。

9)在Eclipse中:在对话框中点击“Add…””按钮。

10)在Eclipse中:在对话框中,确保存储库旁边的复选框被选中,然后单击“Finish”。

11)在Eclipse中:在对话框中选择存储库并单击“Next”。

12)在Eclipse中:在对话框中选择“Import existing projects”单选按钮,选择“Working Directory”,然后点击“Next”。

13)在Eclipse中:在对话框中选中你想要进行的项目旁边的复选框,然后单击“完成”。

14)在Eclipse中:如果需要,重命名存储库中的任何项目。(为了保持Eclipse和文件系统之间的一致性,将它们的名称与存储库目录/文件夹中的项目目录/文件夹相同。)

对于Amazon AWS codecommit用户,

aws codecommit update-repository-name --old-name MyDemoRepo --new-name MyRenamedDemoRepo

参考:

这是一个非常简单的解决方案,尽管有些人可能会认为它“不优雅”或“黑客”,它掩盖了我的git不专业。

Verify that your local repo has everything committed and pushed (to remote origin). Go to the website of the remote host (for example, https://github.com/User/project-original-name). Follow the host's instructions to rename the repo (will differ from host to host, but usually Settings is a good starting point). (For the purposes of this guide, suppose you renamed your repo to "project-new-name".) Locally remove your whole repo (e.g., rm -r project-original-name). Do a "fresh checkout": git clone https://github.com/User/project-new-name

注意:如果回购的另一个用户不遵循这些说明,只是在未来进行拉取,我不知道这会产生什么影响。

@Parison

Server Side: mv oldName.git newName.git
Client Side: ./.git/config change [remote "origin"] | url to newName.git