Updates to the Git Commit Graph Feature
Updates to the Git Commit Graph Feature
Finally, the most immediately-visible improvement is the time it takes to sort commits by topological order.
This algorithm is the critical path for git log --graph
.
Before the commit-graph, Git needed to walk every reachable commit before returning a single result.
Sounds Great! What do I need to do?
If you are using Git 2.23.0 or later, then you have all of these benefits available to you! You just need to enable the following config settings:
-
git config --global core.commitGraph true
: this enables every Git repo to use the commit-graph file, if present. -
git config --global gc.writeCommitGraph true
: this setting tells thegit gc
command to write the commit-graph file whenever you do non-trivial garbage collection. Rewriting the commit-graph file is a relatively small operation compared to a full GC operation. -
git commit-graph write --reachable
: this command will update your commit-graph file to contain all reachable commits. You can run this to create the commit-graph file immediately, instead of waiting for your first GC operation.
In the recently-released Git version 2.24.0, core.commitGraph
and gc.writeCommitGraph
are on by default, so you don’t need to set the config manually. If you don’t want commit-graph files, then explicitly disable these settings and tell us why this isn’t working for you. We’d love to hear your feedback!