Setting a submodule to follow a branch
suggest changeA submodule is checked out at a specific commit (the gitlink, a special entry in the parent repository’s index).
You can instead update that submodule to the latest commit of a branch on the submodule’s remote.
Rather than entering each submodule and running git checkout --track origin/abranch and then git pull, from the parent repository run:
git submodule update --remote --recursive
Since the SHA1 of the submodule would change, you would still need to follow that with:
git add .
git commit -m "update submodules"
That supposes the submodules were:
- either added with a branch to follow:
git submodule add -b abranch -- /url/of/submodule/repo
- or configured (for an existing submodule) to follow a branch:
cd /path/to/parent/repo
git config -f .gitmodules submodule.asubmodule.branch abranch
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents