Skip to content
Latchkey

git submodule update Command in CI

git submodule update checks out each submodule at the commit recorded by the superproject.

Repos with submodules need an extra step after clone to populate them. CI almost always runs the init plus recursive form so nested dependencies are present before the build.

Common flags

  • --init - initialize any submodules that have not been set up yet
  • --recursive - recurse into nested submodules (submodules of submodules)
  • --depth N - shallow-fetch submodule history to speed up CI
  • --remote - update to the latest commit on the submodule branch instead of the pinned SHA
  • --jobs N / -j N - clone or fetch submodules in parallel

Example

shell
# Populate all submodules after a clone in CI
git submodule update --init --recursive --depth 1 --jobs 4

In CI

If a build complains about missing headers or empty submodule directories, the pipeline forgot --init --recursive. Add --depth 1 to keep submodule fetches shallow and --jobs to parallelize when there are many.

Key takeaways

  • git submodule update --init --recursive is the standard CI line to populate nested repos.
  • --depth 1 keeps submodule fetches fast, mirroring the shallow superproject clone.
  • Empty submodule dirs in CI almost always mean the init step was skipped.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →