Interview Prep/Git & GitHub/Remotes, Collaboration and Pull Requests

A CI job clones a 10 GB repo on every run and takes 8 minutes. How do you speed it up?

IntermediateScenarioRemotes, Collaboration and Pull Requests
Answer

Situation read → CI rarely needs full history.

What I'd do →

  1. Shallow clone: git clone --depth 1 --branch main URL. In GitHub Actions, actions/checkout defaults to fetch-depth: 1.
  2. Skip file contents until needed: git clone --filter=blob:none (partial clone).
  3. Limit the tree with git sparse-checkout set services/api.
  4. Cache the repo between runs on persistent runners.

Why → Less data transferred means less time. Only jobs that need history (changelogs, git describe, bisect) set fetch-depth: 0.

Interview tip → Mention the blob-less partial clone for large monorepos.

All Git & GitHub questions Roadmap: Git & GitHub

More on Remotes, Collaboration and Pull Requests