Docs feedback: GIT_SUBMODULE_STRATEGY doesn't allow for specifying branch tracking

In the documentation for using GIT submodules: https://docs.gitlab.com/ee/ci/git_submodules.html#configuring-the-gitmodules-file

There is an example of a .gitmodules file:

[submodule "project"]
  path = project
  url = ../../group/project.git

I understand that Git V 1.8.2 allows for specifying a branch, and the new .gitmodules file looks like this:

[submodule "project"]
  path = project
  url = ../../group/project.git
  branch = master

However I found that using GitLab's flag for automated Git submodule setup:

variables:
  GIT_SUBMODULE_STRATEGY: recursive

This ignores branch specification. I had to replace that with the (I guess) older style before_script to this:

before_script:
  - git submodule sync --recursive
  - git submodule update --remote --recursive

(or more specifically I HAD to specify the --remote flag to get the latest submodule commit on the branch that I specified). I think this should either be incorporated into the GIT_SUBMODULE_STRATEGY logic automatically, or at least the docs should mention how to specify a particular branch when using git submodules.

Edited Sep 02, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading