What is the git commit-graph feature?
Why Interviewers Ask This
Interviewers ask this to evaluate whether you have the depth of knowledge needed to mentor others and lead technical decisions. The expected answer goes beyond definitions into practical implications and real-world consequences.
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.
Pro Tip
Back up your answer with a specific project or situation. Saying 'In my last Git & GitHub project, I used this when...' immediately makes your answer more credible and memorable.
Previous
What is the packfile format in Git?
Next
What is Git's garbage collection and how does it work?