Setting a submodule to follow a branch

suggest change

A submodule is always checked out at a specific commit SHA1 (the “gitlink”, special entry in the index of the parent repo)

But one can request to update that submodule to the latest commit of a branch of the submodule remote repo.

Rather than going in each submodule, doing a git checkout abranch --track origin/abranch, git pull, you can simply do (from the parent repo) a:

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 -b abranch -- /url/of/submodule/repo
cd /path/to/parent/repo
git config -f .gitmodules submodule.asubmodule.branch abranch

Feedback about page:

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

Table Of Contents