With git submodule update
I don’t see an option to specify branch. What happens is, it will fetch either all branches or one (if --single-branch
is specified), which is default, but not the custom.
With very big repositories, it is problematic, because I have to fetch wrong branches and then it will checkout from another “reference”, not much related with default branch, making it much longer to update submodule and also taking more space (as it will fetch unnecessary branch).
Even if I have .gitmodules
with branch specified, it is ignored. For example
let say default branch is master
and I have this in .gitmodules
:
[submodule "my/path/to/sub"]
path = my/path/to/sub
url = [email protected]:org/sub.git
branch = 16.0
I would expect when doing git submodule update --init --single-branch
, to fetch 16.0
branch, but what it does, it will fetch master
branch and will then checkout to commit that is referenced by superproject.