问题描述
我在 .gitmodules 中有子模块列表.我想下载特定的子模块,即 grpc 仅当在配置文件中启用了某些选项为 true 时.由于我的构建有时不需要 grpc.所有子模块都在第三方目录中.所以 .gitmodules 就像:
I have list of submodules in .gitmodules.I want to download a specific submodule i.e grpc only if there is some option enabled as true in config file.Since grpc is not required at times for my build.All submodules are in third-party directory.So .gitmodules is like:
[submodule "third-party/libzip"]
path = third-party/libzip
url = https://github.com/nih-at/libzip.git
[submodule "third-party/sqlite"]
path = third-party/sqlite
url = https://github.com/mackyle/sqlite.git
branch = sqlite-3.23.1
[submodule "third-party/grpc"]
path = third-party/grpc
url = https://github.com/grpc/grpc.git
还有一种方法可以在执行命令时专门排除子模块:
Also is there a way to exclude the submodule specifically while executing command:
git submodule update --init --recursive
我想在子模块更新时排除 grpc 中的 grpc 和子模块.类似的东西:
I would like to exclude grpc and submodules in grpc while submodule update. Something like:
git submodule update --init --recursive "exclude third-party/grpc"
推荐答案
来自 git 帮助:
更新
通过克隆丢失的子模块并更新已注册的子模块以匹配超级项目的期望子模块的工作树.更新"可以通过多种方式完成,具体取决于命令行选项和 submodule..update 的值配置变量.支持的更新程序是:
Update the registered submodules to match what the superproject expects by cloning missing submodules and updating the working tree of the submodules. The "updating" can be done in several ways depending on command line options and the value of submodule..update configuration variable. Supported update procedures are:
...
...
当没有给出任何选项并且 submodule..update
设置为 none 时,子模块不会更新.
When no option is given and submodule.<name>.update
is set to none, the submodule is not updated.
所以在配置文件中设置update = none
.您还可以在 --
之后明确给出路径以仅更新特定的子模块.要即时执行此操作而不更改您的配置文件,@PrashantShubham 指出您可以:
So set update = none
in the configuration file. You can also explicitly give paths after --
to only update specific submodules. To do this on the fly and not change your configuration file, @PrashantShubham notes you can:
git -c submodule."third-party/grpc".update=none submodule update --init --recursive
这篇关于如何从更新中排除特定的 git 子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!