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


当前回答

在服务器端,像往常一样使用mv命令重命名存储库: mv oldName。git newName.git 然后在客户端,将[remote "origin"] URL的值更改为新的值: url = example.com/newName.git

这对我很管用。

其他回答

这是一个非常简单的解决方案,尽管有些人可能会认为它“不优雅”或“黑客”,它掩盖了我的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

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

简单来说,只需删除Eclipse项目(不要选择磁盘上的内容),然后重新导入该项目。

Eclipse将识别连接到Git的项目,并将其放入Git透视图中。

这招很管用。

如果你正在使用GitLab或GitHub,那么你可以图形化地修改这些文件。

使用GitLab

转到项目设置。在那里,您可以修改项目的名称,最重要的是,您可以重命名存储库(这是您开始进入危险部分的时候)。

完成此操作后,必须使用更新本地客户机配置

git remote set-url origin sshuser@gitlab-url:GROUP/new-project-name.git

对于Amazon AWS codecommit用户,

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

参考:

@Parison

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