git - Can Git submodules track same name branch always based on superproject branch name
问题描述
I'm migrating java maven project code to GIT from Perforce (P4) and where every component is released individually and parallel releases supported since git does not allow to checkout by subdir unlike p4 I decided to use Git Submodules.
Now My Superproject has multiple submodules and each submodule has a master, develop and support branch so that my super project's M(master) is tracking M of submodules, D tracking D of submodules and S tracking S of submodules.
superproject
-- pom.xml
submodule 1
-- pom.xml
submodule 2
-- pom.xml
.
.
submodule 10
-- pom.xml
So I want super project branch should track the same branch from all submodules
Superproject (Master, Dev, Support)
- submodule 1 (Master, Dev, Support)
- submodule 2 (Master, Dev, Support)
- ....
- submodule 3 (Master, Dev, Support)
is there an easy way to enforce that whatever branch the superporject is checked out the submodules should be checked out to the same branch as well ?
I tried the adding branchs in .gitmodule file and it works but it needs to be updated after every release before merging it to master from dev branch ( Git Flow).
I'm using this but its becoming manual and confusing to new users.
git submodule foreach --recursive git checkout develop
is there any better way to automate these things ?
解决方案
推荐阅读
- javascript - Target 不是 Electron-React-Typescript-Webpack 应用程序中的 DOM 元素
- swiftui - SwiftUI:传递给子视图的状态没有收到更新?
- javascript - Vue 使用 PHPMailer 提交表单数据
- scala - 使用 scala 将表情符号作为输入提供时获取 Unicode
- python - Vscode:在子文件夹中创建 venv 时,无权访问 .venv python 解释器
- spring-boot - findAllByTimeStampBetweenAndStoreIn(Long startTime, Long endTime, List
商店)不工作 - swift - 与另一个选项卡交互时,如何使 SwiftUI 选项卡视图重新加载?
- python - 如何改进 Python 类的迭代
- python - 如何在 Python 中异或两个字节数组
- node.js - TypeError:this.state.propertydetails.map 不是函数