【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
我已经创建了一个带有子模块的git存储库。 我能够告诉子模块本身更改其远程存储库路径,但我不知道如何告诉父存储库如何更改子模块的远程存储库路径。
如果我有点不幸并且必须手动操作,我不会感到惊讶,因为即使删除子模块也不容易。
#1楼
什么对我有用(在Windows上,使用git版本1.8.3.msysgit.0):
- 使用新存储库的路径更新.gitmodules
- 从“.git / config”文件中删除相应的行
- 删除“.git / modules / external”目录中的相应目录
- 删除签出的子模块目录(不确定是否有必要)
- 运行
git submodule init
和git submodule update
- 确保签出的子模块处于正确的提交状态,然后提交,因为散列可能会有所不同
完成所有这些之后,一切都处于我期望的状态。 我认为存储库的其他用户在更新时会有类似的痛苦 - 在提交消息中解释这些步骤是明智的!
#2楼
这些命令将在命令提示符下完成工作,而不会更改本地存储库上的任何文件
git config --file=.gitmodules submodule.Submod.url https://github.com/username/ABC.git
git config --file=.gitmodules submodule.Submod.branch Development
git submodule sync
git submodule update --init --recursive --remote
请查看博客中的屏幕截图: 将GIT子模块更改为URL / Branch到同一存储库的其他URL /分支
#3楼
git config --file=.gitmodules -e
打开默认编辑器,您可以在其中更新路径
#4楼
简单来说,您只需要编辑.gitmodules文件,然后重新同步和更新:
通过git命令或直接编辑文件:
git config --file=.gitmodules -e
要不就:
vim .gitmodules
然后重新同步和更新:
git submodule sync
git submodule update --init --recursive --remote
#5楼
您应该只能编辑.gitmodules
文件来更新URL,然后运行git submodule sync
以反映对超级项目和工作副本的更改。
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/3149057