Skip to content
Latchkey

How to Reduce Checkout Time with Shallow and Sparse Clones

On big repos, checkout alone can cost minutes. You rarely need full history or the whole tree to build.

actions/checkout defaults to fetch-depth 1, but submodules, large history, and unneeded paths still add time. Trim each.

Keep the clone shallow

fetch-depth: 1 (the default) grabs only the latest commit. Only raise it if a step truly needs history.

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

Sparse-checkout only what you build

In a monorepo, fetch just the directories a job needs.

.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    sparse-checkout: |
      apps/web
      packages/ui

Skip submodules you do not need

submodules: false (default) avoids recursive fetches. Only enable when a job actually compiles a submodule.

Key takeaways

  • Default shallow depth; only deepen when needed.
  • Sparse-checkout the directories a job builds.
  • Skip submodules unless a job needs them.

Related guides

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