我在.gitmodules中有子模块列表。我只想下载特定的子模块(即grpc),前提是在配置文件中启用了true选项。由于有时我的构建不需要grpc。所有子模块都在第三方目录中。所以.gitmodules就像:
[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
还有一种在执行命令时专门排除子模块的方法:
git submodule update --init --recursive
我想在更新子模块时在grpc中排除grpc和子模块。就像是:
git submodule update --init --recursive "exclude third-party/grpc"
从git帮助中:
更新
通过克隆丢失的子模块并更新子模块的工作树,更新已注册的子模块以符合超级项目的期望。根据命令行选项和submodule..update配置变量的值,可以通过几种方式完成“更新”。支持的更新过程是:
...
...
如果未提供任何选项并将
submodule.<name>.update
其设置为none,则不会更新子模块。
因此update = none
在配置文件中进行设置。您还可以在之后明确给出路径,--
以仅更新特定的子模块。要即时执行此操作而不更改配置文件,@ PrashantShubham指出您可以:
git -c submodule."third-party/grpc".update=none submodule update --init --recursive
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句