My parent project has a couple of submodules added to it.
For deployment purposes, I want to checkout a specific branch eg master
, staging
, etc in each submodule and pull the latest commit of this branch in each submodule.
I've checked various answers on SO like the following:
- Easy way to pull latest of all git submodules
- How can I specify a branch/tag when adding a Git submodule?
- Update Git submodule to latest commit on origin
But it's very much confusing as to what is the best practice in 2022. I've git version 2.30.1 (Apple Git-130)
So far I've understood that this command can be used to fetch the latest commit (from their respective remotes) of the branch already mentioned in .gitmodules
file.
git submodule update --remote --merge
But how exactly do I use the -b
option in order to switch the branches in all submodules at the same time, for diff environments deployment?