Setting a submodule to follow a branch

suggest change

A 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:

git submodule add -b abranch -- /url/of/submodule/repo
cd /path/to/parent/repo
git config -f .gitmodules submodule.asubmodule.branch abranch

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents