What is the git commit-graph feature?
Answer
The commit-graph is a binary cache file (.git/objects/info/commit-graph) that stores a precomputed representation of the commit graph — parent pointers, commit dates, root tree hashes, and generation numbers. It dramatically speeds up Git operations that need to traverse commit history: git log, git merge-base, reachability queries. Without commit-graph, Git must parse commit objects one by one by loading from disk. With commit-graph, the traversal uses the binary cache — 10-100x faster for large repos. Generation numbers: each commit has a generation number (1 + max of parent generation numbers). This allows efficient "is commit A an ancestor of commit B?" queries without full traversal — if A's generation number > B's, A cannot be an ancestor. Enable: git config --global core.commitGraph true; git config --global fetch.writeCommitGraph true — update on fetch. Generate: git commit-graph write --reachable. Update: git commit-graph write --reachable --changed-paths (also stores bloom filters for path-based queries — enables fast git log -- path). This feature is especially impactful for large monorepos with hundreds of thousands of commits.
Previous
What is the packfile format in Git?
Next
What is Git's garbage collection and how does it work?