我在.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和子模块。类似于:
git submodule update --init --recursive "exclude third-party/grpc"发布于 2018-09-05 20:30:07
来自git帮助:
更新
通过克隆缺少的子模块并更新子模块的工作树,更新注册的子模块以匹配超级项目的期望。根据命令行选项和submodule..update配置变量的值,可以通过多种方式完成“更新”。支持的更新过程包括:
..。
..。
如果未提供任何选项,并且 submodule.<name>.update 设置为none,则不更新子模块。
因此,在配置文件中设置update = none。您还可以显式地在--之后指定路径,以便仅更新特定子模块。@PrashantShubham指出,要在不更改配置文件的情况下执行此操作,您可以:
git -c submodule."third-party/grpc".update=none submodule update --init --recursivehttps://stackoverflow.com/questions/52179463
复制相似问题