How to fix error: commit-graph is corrupt in Git

GitINTERMEDIATEMEDIUMUpdated Oct 1, 2026ยท 474 views

This error occurs when Git's commit-graph cache file becomes corrupted. The commit-graph is a performance optimization that can be safely deleted and regenerated without data loss.

Quick fix

Fixes error: commit-graph is corrupt

git commit-graph verify
  1. Verify the commit-graph corruption
  2. Delete the corrupt commit-graph file
  3. Regenerate the commit-graph
  4. Run garbage collection to clean up
git โ€” error
git commit-graph verify
error: commit-graph is corrupt

What this error means

The "commit-graph is corrupt" error indicates that Git's commit-graph file has become damaged or inconsistent. The commit-graph is an optional performance feature introduced in Git 2.18 that caches commit ancestry information to speed up operations like `git log --graph`, reachability queries, and other commit traversals. The commit-graph file is stored at `.git/objects/info/commit-graph` (or in `.git/objects/info/commit-graphs/` for split graphs). When Git detects corruption in this file - such as invalid commit positions, bad checksums, or references to non-existent commits - it reports this error. Importantly, the commit-graph is purely a cache. Your actual repository data (commits, trees, blobs) remains intact in the object database. Deleting and regenerating the commit-graph will not cause any data loss - it will only temporarily slow down certain operations until the cache is rebuilt.

Typical symptoms

  • git commit-graph verify reports corruption errors
  • git fsck shows commit-graph related warnings or errors
  • Operations like git log --graph run slowly or fail
  • Error messages mentioning 'invalid commit position' or 'commit-graph is likely corrupt'
  • git gc or git maintenance commands fail with commit-graph errors
  • Performance degradation on large repositories after Git upgrade or downgrade

Common causes

  1. Git version downgrade causing incompatible commit-graph format
  2. Interrupted git gc or commit-graph write operations (power loss, kill signal)
  3. Disk corruption or filesystem errors affecting the commit-graph file
  4. Cloud storage sync (OneDrive, Dropbox, iCloud) interfering with Git files
  5. Concurrent Git operations writing to commit-graph simultaneously
  6. Stale commit-graph referencing commits that have been garbage collected
  7. Bug in older Git version that wrote erroneous generation data

How to fix "error: commit-graph is corrupt"

1Verify the commit-graph corruption

First, confirm that the commit-graph is actually corrupt:

bash
git commit-graph verify

This command checks the commit-graph file against the object database. If corrupt, you'll see output like:

bash
error: commit-graph is corrupt

You can also run a full repository check:

bash
git fsck --full

If core.commitGraph is enabled (the default in modern Git), fsck will also verify the commit-graph.

2Delete the corrupt commit-graph file

The commit-graph is a cache file that can be safely deleted. Remove it:

bash
# Remove the main commit-graph file
rm -f .git/objects/info/commit-graph

# Also remove split commit-graph files if they exist
rm -rf .git/objects/info/commit-graphs/

After deletion, Git will fall back to computing commit ancestry from the object database directly. Operations may be slower until you regenerate the graph.

3Regenerate the commit-graph

Rebuild the commit-graph from scratch:

bash
git commit-graph write --reachable

This scans all reachable commits and builds a new, valid commit-graph file. For large repositories, this may take a few minutes.

To also include generation numbers (improves performance):

bash
git commit-graph write --reachable --changed-paths

Verify the new graph is valid:

bash
git commit-graph verify

You should see no output if the graph is healthy.

4Run garbage collection to clean up

After regenerating the commit-graph, run garbage collection to ensure consistency:

bash
git gc

This will also regenerate the commit-graph if needed. For a more thorough cleanup:

bash
git gc --aggressive --prune=now

Note: --aggressive is slower but produces better compression.

5Disable commit-graph temporarily if issues persist

If you continue to experience problems, you can temporarily disable the commit-graph:

bash
# Disable commit-graph for this repository
git config core.commitGraph false

# Or disable globally
git config --global core.commitGraph false

This tells Git not to use the commit-graph cache, falling back to the object database. Operations will be slower on large repositories but should work reliably.

To re-enable after fixing issues:

bash
git config core.commitGraph true
git commit-graph write --reachable
6Check for cloud sync or filesystem issues

Commit-graph corruption often occurs when Git repositories are stored in cloud-synced folders:

For cloud storage (OneDrive, Dropbox, iCloud, Google Drive):
- Move your Git repositories outside of synced folders
- Or exclude .git directories from syncing

For OneDrive on Windows:

powershell
# Check if OneDrive is causing lock issues
Get-ChildItem -Path .git -Recurse -Filter "*.lock"

For network filesystems (NFS, CIFS, SMB):
These can cause synchronization issues. Consider using local storage for active development.

Check for lock files:

bash
# Remove stale lock files
rm -f .git/objects/info/commit-graph.lock

Advanced notes

Understanding the Commit-Graph: The commit-graph is a binary file that stores commit OIDs, parent relationships, commit dates, and generation numbers. It uses a chunked format with sections like OID Fanout (OIDF), OID Lookup (OIDL), Commit Data (CDAT), and optionally Generation Data (GDA2). The format has evolved across Git versions, which can cause compatibility issues.

Split Commit-Graphs: Git 2.31+ supports split commit-graphs stored in .git/objects/info/commit-graphs/. These allow incremental updates without rewriting the entire graph. To merge split graphs:

bash
git commit-graph write --reachable --split=merge-all

Generation Data Corruption: Git 2.38 fixed a bug where older versions wrote incorrect data in GDA2 (Generation Data) and GDO2 (Generation Data Overflow) chunks. If you downgrade from Git 2.38+, you may encounter issues. The fix renamed the chunks to include "2" in their IDs to distinguish from the erroneous data.

Preventing Future Corruption:

bash
# Enable automatic maintenance (Git 2.30+)
git maintenance start

# This schedules regular gc and commit-graph updates
# Check the schedule:
git config --get-all maintenance.schedule

GitLab/Server Environments: For GitLab Docker installations, regenerate with:

bash
git -C /var/opt/gitlab/git-data/repositories/@hashed/<path>.git commit-graph write --reachable

Checking Object Existence: If you see errors about commits not existing in the object database, your commit-graph may reference garbage-collected commits. This can happen if core.commitGraph was enabled but objects were pruned without updating the graph:

bash
# Check for stale commit references
git config fetch.writeCommitGraph false
git gc --prune=now
git commit-graph write --reachable
git config fetch.writeCommitGraph true

Performance Impact: On large repositories (100K+ commits), the commit-graph can speed up git log --graph by 10-100x. If you've disabled it due to corruption, regenerating it is worthwhile for performance.

Frequently asked questions

What does "error: commit-graph is corrupt" mean?
The "commit-graph is corrupt" error indicates that Git's commit-graph file has become damaged or inconsistent. 18 that caches commit ancestry information to speed up operations like git log --graph, reachability queries, and other commit traversals. git/objects/info/commit-graphs/ for split graphs).
How do I fix "error: commit-graph is corrupt"?
This error occurs when Git's commit-graph cache file becomes corrupted. The commit-graph is a performance optimization that can be safely deleted and regenerated without data loss.
What causes "error: commit-graph is corrupt"?
Git version downgrade causing incompatible commit-graph format Interrupted git gc or commit-graph write operations (power loss, kill signal) Disk corruption or filesystem errors affecting the commit-graph file
Is the "error: commit-graph is corrupt" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading