Git:在所有子模块上递归切换分支( checkout )

标签 git git-submodules git-alias

我正在开发一个包含 submodules 的 git 存储库.我在所有子模块(包括父模块)中都有同名的分支(如 masterdevelopment ..),它们都跟踪其相应的远程分支。

我想一次在所有子模块中 checkout 相同的分支。换句话说,我想要的是,如果我切换到 development父模块分支,所有子模块也应该切换到development分支,以便我的工作树与分支保持一致。

手动执行此操作是痛苦且重复的。有捷径吗?

最佳答案

您可以使用 --recurse-submodule旗帜。例如:git checkout master --recurse-submodules

Using --recurse-submodules will update the content of all initialized submodules according to the commit recorded in the superproject. [https://git-scm.com/docs/git-checkout#git-checkout---no-recurse-submodules]

关于Git:在所有子模块上递归切换分支( checkout ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47834600/

相关文章:

git - InstallShield 项目中的哪些文件需要保留在源代码管理中?

git - 使用 git-subtree 添加远程仓库的子目录

Git 嵌套的子模块和依赖项

Git子模块不 pull

Git 配置别名转义

在后台启动 gitk 和 git gui 的 git 别名

git - 如何在 gitlabhq 中通过 Web 界面在线接受 merge 请求?

git子模块更新 "no-fetch"

git commit --amend 是危险的

java - OpenShift 可以在 DIY Tomcat 上部署 war 还是我应该切换到 OpenStack