我可以为您的问题建议另一种解决方案(替代git-submodules) - gil (git links) 工具
它允许描述和管理复杂的 git 存储库依赖项。
它还为git 递归子模块依赖问题提供了解决方案。
考虑您有以下项目依赖项:
示例 git 存储库依赖关系图
然后您可以.gitlinks
使用存储库关系描述定义文件:
# Projects
CppBenchmark CppBenchmark https://github.com/chronoxor/CppBenchmark.git master
CppCommon CppCommon https://github.com/chronoxor/CppCommon.git master
CppLogging CppLogging https://github.com/chronoxor/CppLogging.git master
# Modules
Catch2 modules/Catch2 https://github.com/catchorg/Catch2.git master
cpp-optparse modules/cpp-optparse https://github.com/weisslj/cpp-optparse.git master
fmt modules/fmt https://github.com/fmtlib/fmt.git master
HdrHistogram modules/HdrHistogram https://github.com/HdrHistogram/HdrHistogram_c.git master
zlib modules/zlib https://github.com/madler/zlib.git master
# Scripts
build scripts/build https://github.com/chronoxor/CppBuildScripts.git master
cmake scripts/cmake https://github.com/chronoxor/CppCMakeScripts.git master
每行以以下格式描述 git 链接:
- 存储库的唯一名称
- 存储库的相对路径(从 .gitlinks 文件的路径开始)
- Git 存储库,将在 git clone 命令中使用 Repository 分支进行结帐
- 不解析空行或以 # 开头的行(视为注释)。
最后,您必须更新您的根示例存储库:
# Clone and link all git links dependencies from .gitlinks file
gil clone
gil link
# The same result with a single command
gil update
结果,您将克隆所有必需的项目并以适当的方式将它们相互链接。
如果您想提交某个存储库中的所有更改以及子链接存储库中的所有更改,您可以使用单个命令来完成:
gil commit -a -m "Some big update"
拉、推命令的工作方式类似:
gil pull
gil push
Gil (git links) 工具支持以下命令:
usage: gil command arguments
Supported commands:
help - show this help
context - command will show the current git link context of the current directory
clone - clone all repositories that are missed in the current context
link - link all repositories that are missed in the current context
update - clone and link in a single operation
pull - pull all repositories in the current directory
push - push all repositories in the current directory
commit - commit all repositories in the current directory
更多关于git 递归子模块依赖问题。