How to fix error: multi-pack-index verification failed in Git

GitINTERMEDIATEMEDIUMUpdated May 31, 2026ยท 203 views

The 'multi-pack-index verification failed' error occurs when Git's MIDX file becomes corrupted or out of sync with the actual pack files. Regenerating the multi-pack-index typically resolves the issue.

Quick fix

Fixes error: multi-pack-index verification failed

# Run full repository verification
git fsck --full

# Specifically verify the multi-pack-index
git multi-pack-index verify

# Check the status of pack files
ls -la .git/objects/pack/

# Look for the MIDX file
ls -la .git/objects/pack/multi-pack-index
  1. Verify the extent of corruption
  2. Regenerate the multi-pack-index
  3. Rebuild pack files if regeneration fails
  4. Run garbage collection
git โ€” error
# Run full repository verification
git fsck --full
# Specifically verify the multi-pack-index
git multi-pack-index verify
# Check the status of pack files
ls -la .git/objects/pack/
# Look for the MIDX file
ls -la .git/objects/pack/multi-pack-index
error: multi-pack-index verification failed

What this error means

This error indicates that Git's multi-pack-index (MIDX) file has failed its integrity check. The multi-pack-index is an optimization feature introduced in Git that creates a single index across multiple pack files, improving performance when your repository has many packs. When Git verifies the MIDX file (either explicitly via `git multi-pack-index verify` or during normal operations), it checks that the index correctly references all objects in the associated pack files. If this verification fails, it usually means the MIDX file has become corrupted or fallen out of sync with the actual pack files. Common scenarios that cause this corruption include: 1. **Interrupted operations** - A `git gc`, `git repack`, or similar operation was interrupted (system crash, killed process) 2. **Race conditions** - Multiple Git processes modified pack files simultaneously, especially during `git repack -ad` 3. **File system issues** - Disk errors, network storage problems, or sync issues in cloud-backed directories 4. **Git version bugs** - Older Git versions (before 2.36) had bugs that could cause MIDX and bitmap data to become out of sync

Typical symptoms

  • Git operations fail with 'multi-pack-index verification failed' error
  • git gc or git repack commands fail unexpectedly
  • git fsck reports problems with the multi-pack-index
  • Repository performance degrades after failed maintenance operations
  • Clone or fetch operations fail with pack-related errors
  • Errors appear after system crash or interrupted Git operation
  • git multi-pack-index verify command fails

Common causes

  1. Interrupted git gc or git repack operation
  2. Race condition between concurrent Git processes modifying pack files
  3. Corrupted multi-pack-index file due to disk or file system errors
  4. Git version bug causing MIDX and bitmap data desynchronization
  5. Pack files deleted or modified without updating the MIDX
  6. Network storage or cloud sync interfering with Git operations
  7. Incomplete clone or fetch operation

How to fix "error: multi-pack-index verification failed"

1Verify the extent of corruption

Before making changes, run diagnostics to understand the scope of the problem:

bash
# Run full repository verification
git fsck --full

# Specifically verify the multi-pack-index
git multi-pack-index verify

# Check the status of pack files
ls -la .git/objects/pack/

# Look for the MIDX file
ls -la .git/objects/pack/multi-pack-index

This helps determine if the issue is isolated to the MIDX or if there's broader repository corruption.

2Regenerate the multi-pack-index

The simplest fix is to delete the corrupted MIDX file and regenerate it:

bash
# Remove the corrupted multi-pack-index file
rm .git/objects/pack/multi-pack-index

# Regenerate the multi-pack-index
git multi-pack-index write

If the write command succeeds, verify the new index:

bash
git multi-pack-index verify

This should complete without errors if the underlying pack files are intact.

3Rebuild pack files if regeneration fails

If regenerating the MIDX fails, the underlying pack files may need to be rebuilt:

bash
# First, disable multi-pack-index temporarily
git config core.multiPackIndex false

# Repack all objects into a fresh pack file
git repack -a -d -f

# Re-enable multi-pack-index
git config core.multiPackIndex true

# Write a new multi-pack-index
git multi-pack-index write

The git repack -a -d -f command:
- -a - Pack all objects into one pack
- -d - Delete old pack files after repacking
- -f - Force recreation even if pack already exists

4Run garbage collection

After rebuilding, run garbage collection to clean up any remaining issues:

bash
# Run garbage collection
git gc

# Or more aggressive cleanup
git gc --aggressive --prune=now

The --aggressive flag spends more time optimizing the repository, which can help ensure consistency.

Note: On large repositories, git gc --aggressive can take a very long time. For most cases, a regular git gc is sufficient.

5Re-clone as last resort

If the repository remains corrupted after the above steps, re-cloning may be the safest option:

bash
# Move the old repository aside
mv myrepo myrepo.backup

# Clone fresh from remote
git clone <remote-url> myrepo

# Copy any uncommitted work from backup
# Check for unstaged changes in backup first
cd myrepo.backup
git status
git stash list

Before deleting the backup:
1. Verify all branches exist in the fresh clone
2. Check that uncommitted changes have been recovered
3. Ensure any local-only branches are pushed to remote

6Disable MIDX if issues persist

If you continue to experience MIDX problems, you can disable the feature entirely:

bash
# Disable multi-pack-index globally
git config --global core.multiPackIndex false

# Remove any existing MIDX files
rm .git/objects/pack/multi-pack-index
rm .git/objects/pack/*.bitmap  # Also remove associated bitmaps

This sacrifices some performance optimization but ensures stability. You can re-enable it later:

bash
git config --global core.multiPackIndex true
git multi-pack-index write

Note: Disabling MIDX may impact performance on repositories with many pack files.

Advanced notes

### Understanding Multi-Pack-Index (MIDX)

The multi-pack-index is a Git feature that improves performance when dealing with multiple pack files. Instead of searching each pack file individually, Git can use a single index that spans all packs.

The MIDX file is stored at .git/objects/pack/multi-pack-index and contains:
- A list of all indexed pack files
- Object ID to pack-file offset mappings
- Optional bitmap data for reachability queries

### Known Race Condition with git repack

There's a documented race condition where git repack -ad can cause MIDX verification failures:

1. Process A reads the MIDX to find object locations
2. Process B runs git repack -ad, deleting old packs and creating new ones
3. Process A tries to access an object in a now-deleted pack
4. Verification fails because the MIDX references non-existent packs

This was partially addressed in Git 2.22+ but can still occur in certain scenarios.

### Git Version Considerations

- Git 2.20 - Introduced basic multi-pack-index support
- Git 2.22 - Added expire and repack subcommands
- Git 2.36 - Fixed bugs causing MIDX and bitmap desynchronization

If experiencing frequent MIDX issues, consider upgrading Git:

bash
# Check current version
git --version

# Update on Ubuntu/Debian
sudo add-apt-repository ppa:git-core/ppa
sudo apt update && sudo apt install git

# Update on macOS
brew upgrade git

# Update on Windows
git update-git-for-windows

### Server-Side MIDX Issues

On Git servers hosting large repositories, MIDX problems can impact multiple users. Consider:

bash
# Schedule maintenance during low-activity periods
git gc --auto

# Use incremental repack for minimal disruption
git multi-pack-index repack --batch-size=0

# Expire old packs after repack
git multi-pack-index expire

### Monitoring Repository Health

Set up periodic verification to catch issues early:

bash
# Add to cron or scheduled task
git fsck --connectivity-only  # Quick check
git multi-pack-index verify    # MIDX-specific check

### Cloud Storage and Network File Systems

MIDX corruption is more common on:
- Network-mounted file systems (NFS, SMB)
- Cloud-synced directories (Dropbox, OneDrive, Google Drive)
- Repositories on external drives

For these scenarios, consider keeping core.multiPackIndex disabled or ensuring proper file locking is in place.

### Recovering Lost Objects

If objects were lost due to corruption:

bash
# Check reflog for recent commits
git reflog

# Attempt to recover dangling objects
git fsck --lost-found
ls .git/lost-found/

# Objects here can potentially be restored
git cat-file -t <object-sha>  # Check object type
git cat-file -p <object-sha>  # Print object contents

Frequently asked questions

What does "error: multi-pack-index verification failed" mean?
This error indicates that Git's multi-pack-index (MIDX) file has failed its integrity check. The multi-pack-index is an optimization feature introduced in Git that creates a single index across multiple pack files, improving performance when your repository has many packs. When Git verifies the MIDX file (either explicitly via git multi-pack-index verify or during normal operations), it checks that the index correctly references all objects in the associated pack files.
How do I fix "error: multi-pack-index verification failed"?
The 'multi-pack-index verification failed' error occurs when Git's MIDX file becomes corrupted or out of sync with the actual pack files. Regenerating the multi-pack-index typically resolves the issue.
What causes "error: multi-pack-index verification failed"?
Interrupted git gc or git repack operation Race condition between concurrent Git processes modifying pack files Corrupted multi-pack-index file due to disk or file system errors
Is the "error: multi-pack-index verification failed" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading