如何正确切换 git 子模块与其他分支?
How to switch git submodule with other branch properly?
我有repo,里面有很多子模块。每个子模块都用 -b branch_rev_1
初始化。我想切换这个 repo 的状态,用 -b branch_rev_2
改变每个子模块的分支(所以我将能够构建具有不同版本的依赖项的应用程序)。
但是在子模块的目录中创建 checkout -b branch_rev_2
不会更改 .gitmodules
文件中的记录。
在 .gitmodules
文件中更改分支名称后,是否有任何方法可以切换所有子模块的状态(反之亦然,同步 .gitmodules
描述和 .git 文件夹中的其他配置后检查内部的特定修订子模块)?
您可以手动(使用编辑器)或使用 git config -f .gitmodules
编辑 .gitmodules
。修改后使用命令 git submodule sync
将其同步到 .git/config
并使用 git submodule update --init --remote
.
更新子模块
我有repo,里面有很多子模块。每个子模块都用 -b branch_rev_1
初始化。我想切换这个 repo 的状态,用 -b branch_rev_2
改变每个子模块的分支(所以我将能够构建具有不同版本的依赖项的应用程序)。
但是在子模块的目录中创建 checkout -b branch_rev_2
不会更改 .gitmodules
文件中的记录。
在 .gitmodules
文件中更改分支名称后,是否有任何方法可以切换所有子模块的状态(反之亦然,同步 .gitmodules
描述和 .git 文件夹中的其他配置后检查内部的特定修订子模块)?
您可以手动(使用编辑器)或使用 git config -f .gitmodules
编辑 .gitmodules
。修改后使用命令 git submodule sync
将其同步到 .git/config
并使用 git submodule update --init --remote
.