更改git子模块的远程存储库

我创建了一个包含子模块的git存储库。 我能够告诉子模块本身更改其远程存储库路径,但我不知道如何告诉父存储库如何更改子模块的远程存储库路径。

我不会感到惊讶,如果我有点运气不好,不得不手动去做,甚至删除子模块也不容易。


您应该只需编辑.gitmodules文件即可更新URL,然后运行git submodule sync将该更改反映到超级项目和工作副本中。


这些命令将在不改变本地存储库上的任何文件的情况下执行命令提示符下的工作

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 /分支


什么对我有用(在Windows上,使用git版本1.8.3.msysgit.0):

  • 使用新存储库的路径更新.gitmodules
  • 从“.git / config”文件中删除相应的行
  • 删除“.git / modules / external”目录中的相应目录
  • 删除检出的子模块目录本身(不确定是否有必要)
  • 运行git submodule initgit submodule update
  • 确保已签出的子模块处于正确的提交,并提交,因为哈希可能会有所不同
  • 做完这一切后,一切都处于我期望的状态。 我想,存储库的其他用户在更新时会有类似的痛苦 - 在你的提交消息中解释这些步骤是明智的!

    链接地址: http://www.djcxy.com/p/16425.html

    上一篇: Changing remote repository for a git submodule

    下一篇: How do I manage conflicts with git submodules?