Skip to content
Latchkey

How to Check Out Submodules Shallow and in Parallel in CI

actions/checkout can fetch submodules recursively, and shallow depth plus parallel jobs cut the time many submodules add.

Submodules multiply clone time on a large repo. Set submodules: recursive to fetch them, keep each shallow, and fetch them in parallel so the slowest submodule, not the sum, bounds checkout time.

Steps

  • Set submodules: recursive on checkout to include nested submodules.
  • Keep fetch-depth: 1 so each submodule is shallow.
  • Parallelize with git submodule update --jobs or configure submodule.fetchJobs.

Workflow

.github/workflows/ci.yml
steps:
  - uses: actions/checkout@v4
    with:
      submodules: recursive
      fetch-depth: 1

Parallel shallow update with plain git

Terminal
git submodule update --init --recursive --depth 1 --jobs 4

Gotchas

  • Private submodules need credentials; provide a token with access or SSH deploy keys.
  • A submodule pinned to a commit not on any branch tip can fail a shallow fetch; deepen that one.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →