Skip to content
Latchkey

How to Use the Commit-Graph to Speed Up Git in CI

git commit-graph write builds an index that makes history walks (log, merge-base, blame) dramatically faster on large repos.

Commands that walk history get slow when there are hundreds of thousands of commits. The commit-graph is a supplemental data structure that answers reachability and topology queries without parsing commit objects. Write it once after fetch and history steps speed up.

Steps

  • After checkout, run git commit-graph write --reachable.
  • Run history-heavy steps (changelog, git log, merge-base) afterward.
  • On persistent runners, enable it globally so every run benefits.

Workflow

.github/workflows/ci.yml
steps:
  - uses: actions/checkout@v4
    with:
      fetch-depth: 0
  - run: git commit-graph write --reachable --changed-paths
  - run: git log --oneline --since="1 month ago" | wc -l

Enable it by default

Terminal
git config --global core.commitGraph true
git config --global fetch.writeCommitGraph true

Gotchas

  • The graph is only useful when history is present; a depth-1 clone has nothing to index.
  • --changed-paths makes path-scoped log much faster but takes longer to write.

Related guides

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