回顾性地将 --recursive 添加到 git 存储库
如果您使用 --recursive
来 git clone
,您也可以获得所有 git 子模块。
如果我在克隆时忘记添加这个神奇的标志(可能会发生),那么我现在如何获取任何子模块?
此外,如何将递归标志设置为未来克隆的默认值?
If you git clone
with --recursive
, you can get all the git submodules too.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以在简单的顶级克隆之后使用此操作:
我不建议让克隆默认执行此操作。如果您积极使用子模块进行开发,而不仅仅是链接到 github 上的第 3 方 OSS 库(您可以千载难逢地升级一次),那么正确的方法是使用 git 从属 或 子树.
You can do it with this after a simple top-level clone:
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 slave or subtree.
从您的存储库的根目录:
这将更新所有已注册的子模块,如果需要的话将它们初始化为 .gitmodules 文件中找到的值,并且还会递归到复杂的子模块(具有自己的子模块的子模块)并初始化和更新它们。
据我所知,默认情况下递归克隆的最简单方法是使用别名来隐藏
git clone
就始终添加选项而言,我认为这是惯用的方法。
据
From the root of your repo:
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 aliasAs far as adding options always, I think that's the idiomatic method.
国际研究委员会,
git 子模块初始化
,git submodule update
不幸的是,我没有看到默认启用递归的选项。
IIRC,
git submodule init
,git submodule update
Unfortunately, I do not see an option to enable recursive by default, however.
看来你不能用别名“clone”覆盖“clone”,所以它是一个新的别名(Abizern的解决方案)或“--recursive”。
是否可以通过 git 别名覆盖 git 命令?< /a>
It appears you can't override "clone" with alias "clone", so it's a new alias (Abizern's solution) or "--recursive".
Is it possible to override git command by git alias?