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 -lEnable it by default
Terminal
git config --global core.commitGraph true
git config --global fetch.writeCommitGraph trueGotchas
- The graph is only useful when history is present; a depth-1 clone has nothing to index.
--changed-pathsmakes path-scoped log much faster but takes longer to write.
Related guides
How to Use Scalar and Git Maintenance for Large Repos in CIUse git scalar and background maintenance to keep a very large repository fast on self-hosted CI runners, ena…
How to Find Changed Files With Git Diff in CIList the files a push or pull request changed in CI with git diff --name-only against the base ref, driving p…