我已经阅读了如何自己删除 git 子模块:
# Delete the relevant section from the .gitmodules file.
git config -f .gitmodules --remove-section submodule.$submodulepath
# Delete the relevant section from .git/config
git config -f .git/config --remove-section submodule.$submodulepath
git rm --cached path_to_submodule # no trailing slash
git commit
rm -rf path_to_submodule
我能做到。但是,当其他人执行某个操作时git pull
,我们如何确保从他们的系统中删除子模块?变化伴随着拉动而来,但据我所知,.gitmodules
其他的不多。所以拉的人还是得跑
git config -f .git/config --remove-section submodule.$submodulepath
rm -rf path_to_submodule
是对的吗?在一个小型开发团队中,我猜你可以告诉每个人运行这些命令,但这并不理想。
是否有一些魔术命令可以自动执行此操作?特别是我想要一些在部署脚本中自动执行此操作的标准方法。在我的脑海中,我不确定脚本是如何知道比以前少一个子模块的。(不是特别有吸引力)我想到的选择是:
.gitmodules
在拉之前和之后做差异- 删除所有子模块,然后运行
git submodule update --init
每个部署。 - 子模块在拉取后确实最终成为一个未跟踪的文件,因此一个可行的选项是在拉取后删除所有包含
.git
子目录的未跟踪目录,但您可能会删除想要保留的内容。
任何更好的选择表示赞赏。