我正在开发一个包含 submodules
的 git 存储库.我在所有子模块(包括父模块)中都有同名的分支(如 master
、development
..),它们都跟踪其相应的远程分支。
我想一次在所有子模块中 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/