Skip to content

format-commit-graph Git Command Guide

The git format-commit-graph format stores a list of commit OIDs and associated metadata to enable fast commit graph operations. The commit-graph format includes generation numbers, root tree OIDs, commit dates, parent references, and optionally Bloom filters for changed paths.

  • 4-byte signature: ‘C’, ‘G’, ‘P’, ‘H’
  • 1-byte version number: Currently version 1
  • 1-byte hash version: 1 = SHA-1, 2 = SHA-256
  • 1-byte number of chunks (C): Number of data chunks
  • 1-byte number of base graphs (B): Number of base commit-graphs
DataDescription
Generation numberCommit’s topological generation number
Root tree OIDSHA-1/SHA-256 hash of the root tree object
Commit dateAuthor date of the commit
Parent references32-bit indices into the commit-graph array
Bloom filterOptional filter of changed paths vs first parent
VersionFeatures
1Basic commit metadata storage
ChunkDescription
OIDFBase commit-graph OIDs
OIDLOID lookup table
CDATCommit data (dates, generations)
BIDXBase graphs chunk indices
PIDXParent indices
GIDXGeneration data index
Terminal window
git commit-graph write --reachable

Creates commit-graph file for reachable commits from all refs.

Terminal window
ls -la .git/objects/info/commit-graph

Verify commit-graph file exists in repository.

Terminal window
git commit-graph verify

Verify commit-graph integrity and show statistics.

Terminal window
git commit-graph write --stdin-commits < commits.txt

Create commit-graph for commits listed in file.

Terminal window
git commit-graph write --split --reachable

Write incremental commit-graph allowing future updates.

Terminal window
git commit-graph write --reachable --hash-version=2

Create SHA-256 compatible commit-graph (Git 2.29+).

How does commit-graph improve performance?

Section titled “How does commit-graph improve performance?”

The commit-graph stores commit metadata (dates, generations, parents) in a contiguous format, reducing I/O when traversing commit history.

What operations benefit from commit-graph?

Section titled “What operations benefit from commit-graph?”

Operations like git log --oneline, git branch --contains, and merge-base calculations see significant speedups.

Run git commit-graph verify to check integrity or git log --oneline -500 | tail -10 to test if it’s automatically loaded.

Yes, use newer Git versions with git commit-graph write --reachable --hash-version=2 for SHA-256 support.

What happens if commit-graph is corrupted?

Section titled “What happens if commit-graph is corrupted?”

If corrupted, Git falls back to original object traversal. Regenerate with git commit-graph write --reachable --force.

Generation numbers represent topological order, enabling efficient ancestor queries and avoiding redundant recursive traversals.

  1. Repository Performance: Speeds up git operations in large repositories
  2. Scalability: Enables efficient operations on repositories with millions of commits
  3. Memory Efficiency: Reduces memory usage during commit graph traversals
  4. CI/CD Optimization: Limits ancestor walk overhead in build pipelines
  5. Large Projects: Essential for enterprises repos with complex merge histories
  6. Network Efficiency: Optimizes fetch and clone operations in distributed workflows