我可以针对您的问题提出另一种解决方案(git-submodules 的替代方案) - gil (git links) tool
它允许描述和管理复杂的 git 存储库依赖项。
它还为git recursive submodules dependency problem 提供了解决方案。
假设您有以下项目依赖项:
sample git repository dependency graph
然后你可以定义.gitlinks文件和repositories关系描述:
# 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 clone 命令中使用的 Git 存储库
用于结帐的存储库分支
- 不解析空行或以 # 开头的行(视为注释)。
最后,您必须更新您的根示例存储库:
# 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 recursive submodules dependency problem。