git - 将 git 的 submodule.recurse 配置选项设置为 true 有什么缺点?

标签 git git-submodules

这个问题Is there a way to make git pull automatically update submodules?有一个像这样配置 git 的公认答案:

git config --global submodule.recurse true

就像对该答案的评论之一一样,我想知道为什么这不是 git 的默认行为;更准确地说,设置此配置选项的缺点是什么?

最佳答案

此选项在 commit 046b482 中引入, 最初用于工作树 操纵命令 ( read-tree/checkout/reset )

git grep/fetch/pull/push紧随其后。
然而,作为the documentation mentions ,与下面的其他命令不同,clone 仍然需要自己的递归标志: git clone --recurse-submodules <URL> <directory> .
看这个recent discussion :

This was a design decision once it was introduced, as the git clone might be too large.
Maybe we need to revisit that decision and just clone the submodules if submodule.recurse is set.

由于所涉及的子模块的数量/大小可能很大,目前默认行为是默认不递归包含它们。

它们的主要缺点是由于必须在每个子模块(以及它们各自的子模块)中递归进行而可能引入的时间开销。
如果你有很多,并且不需要全部,最好关闭该选项,并指定 --recursive当你需要的时候。

然而,一个优点是在切换分支时避免看到“未跟踪文件”,as seen in this discussion .


警告,从 Git 2.34(2021 年第 4 季度)开始,git clone --recurse-submodules , 意味着一个简单的 git pull将递归到子模块中。

即使 git config --global submodule.recurse 设置。

参见“Is there a way to make git pull automatically update submodules?”。

关于git - 将 git 的 submodule.recurse 配置选项设置为 true 有什么缺点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53514521/

相关文章:

git - 来自 Nginx 的 502 Bad Gateway for large GitLab fork

git - 在 GIT 中丢失了我的 promise 。你会不小心删除提交吗?

Git Fetch 与 Git Fetch Origin

git - 为什么 git rebase 覆盖我的本地更改?如何避免覆盖?

Git 子模块准备稀疏 checkout

Xcode 机器人 : git submodules not initialized

ios - 使用两个 Apple 开发者帐户使用 git 协作处理 Xcode 项目

Git:克隆项目时未 pull 子模块

azure - 如何在 Azure DevOps 中隐藏分支

git - 如何在不丢失子模块的情况下压缩所有提交?