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: 1Sparse-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/uiSkip 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
How to Optimize CI for a MonorepoMake monorepo CI fast: affected-project detection, sparse checkout, per-package caching, and a remote cache s…
How to Avoid Redundant Builds with Path FiltersUse path filters and changed-file detection in GitHub Actions so jobs only run when relevant files change, sk…
How to Speed Up GitHub Actions: 9 High-Impact TacticsMake GitHub Actions faster: caching, parallelization, test splitting, Docker layer caching, slimmer images, a…
How to Reduce Cold Starts in CICut CI cold-start time: warm dependency caches, prebuilt images, and warm-pool runners that skip the provisio…