Commit-Graph

The Commit-Graph File and Faster History Walks

Walking history means inflating one compressed commit object after another. The commit-graph file stores every commit's tree, parents, date and generation number in one binary table instead. BookNest's 55 commits are too few to notice, so Sam uses Git 1,932 's own repository, cloned without trees (Partial Clone):

Counting 81,000 commits before and after writing a commit-graphShell
git clone -q --bare --filter=tree:0 https://github.com/git/git.git ../git.git
cd ../git.git
TIMEFORMAT="%R seconds"
time git rev-list --count v2.55.0
git commit-graph write --reachable
ls objects/info
time git rev-list --count v2.55.0
cd ../booknest
Output
81348
0.745 seconds
commit-graph
81348
0.053 seconds

The walk became about 14 times faster (a shared 4-CPU machine, so compare the ratio). Generation numbers let git merge-base and git log --graph stop walking early. --changed-paths adds a Bloom filter per commit that answers "did this commit touch this path?" with "no" or "maybe", speeding up git log -- <path>; commitGraph.changedPaths (Git 2.52) makes it the default. git gc and git maintenance keep the file current.