如何从更新中排除特定的git子模块? [英] How to exclude a specific git submodule from update?

查看:185
本文介绍了如何从更新中排除特定的git子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.gitmodules中有子模块列表. 我只想在配置文件中将某些选项启用为true的情况下才下载特定的子模块,即grpc. 由于有时我的构建不需要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.<name>.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子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆