回顾性地将 --recursive 添加到 git repo
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4251940/
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
Retrospectively add --recursive to a git repo
提问by kenneth
If you git clone
with --recursive
, you can get all the git submodules too.
如果您git clone
使用--recursive
,您也可以获得所有 git 子模块。
If I've forgotten to add this magical flag when cloning, as can happen, how do I now go and get any submodules?
如果我在克隆时忘记添加这个神奇的标志,这可能发生,我现在如何去获取任何子模块?
Additionally, how can I set the recursive flag as a default for future clones?
此外,如何将递归标志设置为未来克隆的默认值?
回答by Adam Dymitruk
You can do it with this after a simple top-level clone:
您可以在一个简单的顶级克隆之后使用它:
git submodule update --init --recursive
I would not recommend making clone do this by default. The proper way to do this if you are using submodules aggressively for development and not just linking to 3rd party OSS libs on github that you may upgrade once in a blue moon, is to use git slaveor subtree.
我不建议让克隆默认执行此操作。如果您正在积极使用子模块进行开发,而不仅仅是链接到 github 上的 3rd 方 OSS 库(您可能会在蓝月亮中升级一次),那么正确的方法是使用git slave或subtree。
Hope this helps.
希望这可以帮助。
回答by Tim Visher
From the root of your repo:
$ git submodule update --init --recursive
That will update any and all registered submodules, initializing them if need be to the value as found in the .gitmodules file, and also recurse into complex submodules (ones with submodules of their own) and initialize and update them as well.
The easiest way I know of to make cloning recursively the default would be to shadow
git clone
with an alias$ git config --global alias.clone = 'clone --recursive'
As far as adding options always, I think that's the idiomatic method.
从你的回购的根:
$ git submodule update --init --recursive
这将更新任何和所有注册的子模块,如果需要将它们初始化为 .gitmodules 文件中的值,并且还会递归到复杂的子模块(具有自己的子模块的子模块)并初始化和更新它们。
我所知道的使递归克隆成为默认值的最简单方法是
git clone
使用别名进行阴影$ git config --global alias.clone = 'clone --recursive'
至于总是添加选项,我认为这是惯用的方法。
回答by user502515
IIRC,
git submodule init
,
git submodule update
国际研究中心,
git submodule init
,
git submodule update
Unfortunately, I do not see an option to enable recursive by default, however.
不幸的是,我没有看到默认情况下启用递归的选项。
回答by Dell Kronewitter
It appears you can't override "clone" with alias "clone", so it's a new alias (Abizern's solution) or "--recursive".
看来你不能用别名“clone”覆盖“clone”,所以它是一个新的别名(Abisern 的解决方案)或“--recursive”。