问题描述
.gitmodule
文件仅指定模块存储库url。 git submodule
如何知道要下载哪个版本?它似乎总是检查出最新版本。那么,开发人员如何确保主项目和子模块之间的兼容性? 您的子模块表示为一个特殊的条目,一种特殊的模式(称为 ,请参阅) 新文件模式160000
索引0000000..4c4c5a2
所以它没有检出最新版本,而是一个特定的SHA1,这样做在(请参阅。
这并不意味着您无法更新子模块,因为我在中解释。
有关子模块的更多信息,以及潜在您为什么不愿使用它们(!)的原因,请阅读清醒的文章(也。
p>The .gitmodule
file only specifies the module repository url. How does git submodule
know which version to download? It seems to be always checking out the latest version. Then, how does developers ensure compatibility between the main project and the sub modules?
Your submodule is represented as a special entry with a special mode (called a gitlink, see "Nested git repositories without submodules?"):
(See "Checkout past git submodule commit")
new file mode 160000
index 0000000..4c4c5a2
So it isn't checking out the "LATEST" version, but always a specific SHA1, and it does so in a DETACHED HEAD
mode (see "How to make submodule with detached HEAD
to be attached to actual HEAD
?".
That doesn't mean you can't update a submodule, as I explain in "true nature of submodules".
For more on submodules, and on potentially why you might not want to use them(!), read the sobering article "Why your company shouldn’t use Git submodules", from Amber Yust (also on SO).
Just one small extract, for kicks and giggles (emphasis mine):
Err... "ouch".
Note that now a submodule can track the latest from a branch: see "git submodule tracking latest".
这篇关于git子模块的工作方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!