.gitmodules 和在 .git/config 中指定子模块的区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10453520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
difference between .gitmodules and specifying submodules in .git/config?
提问by Stann
Probably very silly question, - but I've been specifying submodules up until now in .gitmodules file. It recently struck me that perhaps it's possible to just use .git/config for the same reason so I won't have to keep extraneous file in working directory?
可能是非常愚蠢的问题,但到目前为止我一直在 .gitmodules 文件中指定子模块。最近让我感到震惊的是,出于同样的原因,也许可以只使用 .git/config,这样我就不必在工作目录中保留无关文件?
.git/config :
.git/配置:
[submodule "path/to/repo"]
url = [email protected]:username/repo.git
.gitmodules
.gitmodules
[submodule "path/to/repo"]
path = path/to/repo
url = [email protected]:username/repo.git
Are these basically the same things?
这些是基本相同的东西吗?
采纳答案by Artefact2
Same answer than .git/info/exclude
and .gitignore
.
与.git/info/exclude
和 的答案相同.gitignore
。
The .gitmodules
file can be included in the repository and shared with everyone (that is, it can be added and committed like any regular file), whereas anything in .git
(like .git/config
) is private (you cannot add it in the repository).
该.gitmodules
文件可以包含在存储库中并与所有人共享(也就是说,它可以像任何常规文件一样添加和提交),而.git
(如.git/config
)中的任何内容都是私有的(您不能将其添加到存储库中)。
回答by Philip Oakley
The git submodule sync
will update your config file with the details from the .gitmodules file, so the latter should be considered the 'master' - it's passed between repos as stated by @Artefact2.
在git submodule sync
将更新从.gitmodules文件的细节您的配置文件,因此后者应被视为“主” -它由@ Artefact2规定回购之间传递。
This is useful when submodule URLs change upstream and you need to update your local repositories accordingly.
当子模块 URL 更改上游并且您需要相应地更新本地存储库时,这很有用。