git - 如何从更新中排除特定的 git 子模块?

标签 git version-control git-submodules

我在 .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 帮助:

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:

...

...

When no option is given and submodule.<name>.update is set to none, the submodule is not updated.

所以设置update = none在配置文件中。您还可以在 -- 之后明确给出路径只更新特定的子模块。要即时执行此操作而不更改配置文件,@PrashantShubham 指出您可以:

git -c submodule."third-party/grpc".update=none submodule update --init --recursive

关于git - 如何从更新中排除特定的 git 子模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52179463/

相关文章:

Git压缩分支中的所有提交而不会发生冲突

git - 将文件添加到 github :gist thats not text

git - 如何在 aptana 中禁用 git?或者关掉它?

git - 重新设置一个分支,包括它的所有子分支

git - 如何更新包含子模块的 git repo?

git - 清理克隆上的 git 子模块的工作流程是什么?

swift - 为什么我的 Swift 应用程序不能使用 xcodebuild 构建,但可以使用 XCode 构建?

version-control - 如何在 mercurial 中过滤具有部分名称匹配的命名分支?

Git:有没有办法弄清楚提交是从哪里挑选出来的?

git - 为什么 'git submodule update' 会跳过子模块?