Pra*_*sha 5 git version-control git-submodules
我有.gitmodules中的子模块列表.我想下载一个特定的子模块,即只有在配置文件中启用某个选项为true时才下载grpc.因为我的构建有时不需要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
Run Code Online (Sandbox Code Playgroud)
还有一种方法可以在执行命令时专门排除子模块:
git submodule update --init --recursive
Run Code Online (Sandbox Code Playgroud)
我想在子模块更新时排除grpc中的grpc和子模块.就像是:
git submodule update --init --recursive "exclude third-party/grpc"
Run Code Online (Sandbox Code Playgroud)
从git帮助:
更新
通过克隆缺失的子模块并更新子模块的工作树,更新已注册的子模块以匹配超级项目所期望的内容."更新"可以通过多种方式完成,具体取决于命令行选项和子模块.update配置变量的值.支持的更新程序包括:
...
...
如果未给出任何选项且
submodule.<name>.update设置为none,则不更新子模块.
所以update = none在配置文件中设置.您还可以显式提供--仅更新特定子模块的路径.要在运行中执行此操作而不更改配置文件,@ PrashantShubham会注意到您可以:
git -c submodule."third-party/grpc".update=none submodule update --init --recursive
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2264 次 |
| 最近记录: |