This warning occurs when Git detects corruption in the reachability bitmap index file, which is used to optimize operations like fetching and cloning. The fix involves regenerating the bitmap file using git repack or git gc.
The "bitmap file is corrupt" warning indicates that Git has detected data corruption in the `.bitmap` file stored in your repository's `.git/objects/pack/` directory. Reachability bitmaps are an optimization feature that allows Git to quickly determine which objects are reachable from certain commits, dramatically speeding up operations like `git fetch`, `git clone`, and object counting. When this file becomes corrupted, Git will still function correctly but may fall back to slower traversal algorithms. The warning is informational - your actual repository data (commits, trees, blobs) is not affected. Git simply cannot use the corrupted bitmap for optimization and will ignore it. Bitmap corruption typically happens due to: - Interrupted disk writes during garbage collection or repacking - File system errors or hardware issues - Incomplete transfer when cloning or fetching - Running multiple Git processes that attempted to write bitmaps simultaneously Since the bitmap is purely an optimization artifact and not essential data, fixing this issue is straightforward: simply regenerate the bitmap file.
Before regenerating the bitmap, run a full repository check to ensure there are no deeper issues:
# Run a full file system check
git fsck --full
# Check for any other corruption
git fsck --strictIf git fsck reports any errors beyond the bitmap warning, address those first. The bitmap warning alone is not a sign of repository corruption - it's just an optimization file that needs regeneration.
If fsck shows all objects are valid, proceed to regenerate the bitmap.
The bitmap file is located in your repository's pack directory. You can safely remove it:
Locate and remove the bitmap file:
# Find bitmap files in the repository
ls -la .git/objects/pack/*.bitmap
# Remove the corrupt bitmap file(s)
rm -f .git/objects/pack/*.bitmapOn Windows (PowerShell):
Get-ChildItem .git\objects\pack\*.bitmap
Remove-Item .git\objects\pack\*.bitmap -ForceRemoving the bitmap file is safe - it only affects performance, not data integrity. Git will simply skip using bitmaps until a new one is generated.
The recommended way to regenerate the bitmap is using git repack with the bitmap writing option:
# Repack all objects and generate a new bitmap
git repack -a -d -bFlags explained:
- -a: Pack all objects into a single pack (required for bitmaps)
- -d: Delete redundant packs after repacking
- -b: Write a reachability bitmap index
For large repositories, add progress output:
git repack -a -d -b --progressThis command will create a new .bitmap file alongside your pack file in .git/objects/pack/.
You can also use git gc (garbage collection) to regenerate the bitmap:
# Run garbage collection which includes repacking with bitmaps
git gc
# Or force an aggressive cleanup
git gc --aggressiveTo ensure bitmaps are written during gc:
# Check current configuration
git config --get repack.writeBitmaps
# Enable bitmap writing if not set
git config repack.writeBitmaps true
# Then run gc
git gcNote: git gc --aggressive takes significantly longer but produces better compression. For most cases, regular git gc is sufficient.
After repacking, verify that a new bitmap file was created:
# Check for new bitmap files
ls -la .git/objects/pack/*.bitmap
# Run a git operation to confirm no warning appears
git count-objects -v
# Or run fsck to verify everything is clean
git fsckIf no bitmap file was created, check for conditions that prevent bitmap generation:
- Multiple pack files exist (bitmap requires a single pack)
- The pack.packSizeLimit configuration is set (forces multiple packs)
- The repository uses alternates (bitmaps not supported with alternates)
Check for issues:
# Count pack files
ls -l .git/objects/pack/*.pack | wc -l
# Check packSizeLimit
git config --get pack.packSizeLimit
# Check for alternates
cat .git/objects/info/alternates 2>/dev/nullIf your repository has multiple pack files, traditional single-pack bitmaps won't work. Instead, use the multi-pack index (MIDX) with bitmaps:
# Write a multi-pack index with bitmap
git multi-pack-index write --bitmap
# Verify the MIDX was created
ls -la .git/objects/pack/multi-pack-index*Requirements for MIDX bitmaps:
- Git version 2.32 or later
- Multiple pack files in the repository
Or consolidate into a single pack:
# Remove pack size limit if set
git config --unset pack.packSizeLimit
# Repack into single pack with bitmap
git repack -a -d -bChoose the MIDX approach if you intentionally maintain multiple packs (e.g., for incremental backups), otherwise consolidate into a single pack.
Understanding Reachability Bitmaps:
Reachability bitmaps are an optimization introduced to speed up object traversal in Git. They store precomputed information about which objects are reachable from specific commits, eliminating the need to traverse the entire commit graph.
How bitmaps work:
1. Git selects certain commits (typically recent branch tips) as "bitmap commits"
2. For each bitmap commit, it stores a bitmap marking all reachable objects
3. During operations like fetch, Git uses these bitmaps instead of walking the graph
4. This can reduce clone/fetch time from minutes to seconds for large repositories
Bitmap file location:
.git/objects/pack/pack-<hash>.bitmapThe bitmap file corresponds to a specific pack file and is only valid for that pack.
When bitmaps cannot be used:
Several conditions prevent bitmap creation:
- Multiple pack files: Traditional bitmaps require a single pack containing all objects
- pack.packSizeLimit set: Forces multiple smaller packs
- Alternates configured: Bitmaps don't work with alternate object directories
- Shallow clone: Some objects may be missing
Server-side considerations:
Bitmaps are especially important for Git servers hosting large repositories:
# Enable bitmaps for server repositories
git config repack.writeBitmaps true
# Configure gc to maintain bitmaps
git config gc.writeBitmapHashCache truePerformance impact of corrupt/missing bitmaps:
Without bitmaps, Git falls back to full object traversal:
- Clone operations walk the entire commit history
- Fetch operations enumerate all objects
- Large repositories (100k+ commits) see dramatic slowdowns
Multi-pack index (MIDX) bitmaps (Git 2.32+):
For repositories that maintain multiple packs, MIDX bitmaps provide the optimization:
# Write MIDX with bitmap
git multi-pack-index write --bitmap
# Verify and maintain MIDX
git multi-pack-index verify
git multi-pack-index expire
git multi-pack-index repackMIDX bitmaps are stored in:
.git/objects/pack/multi-pack-index-<hash>.bitmapPreventing future corruption:
1. Avoid interrupting git gc/repack: Let these operations complete
2. Ensure stable power/filesystem: Use UPS for critical servers
3. Don't run concurrent gc operations: Only one gc should run at a time
4. Monitor disk health: Failing disks often corrupt files silently
For CI/CD environments:
If you see this warning in CI/CD:
# Clean rebuild approach
git gc --prune=now
# Or simply ignore the warning for ephemeral environments
# The warning doesn't affect correctnessConfiguration options:
# Enable/disable bitmap writing
git config repack.writeBitmaps true
# Configure bitmap hash cache (improves delta calculations)
git config pack.writeBitmapHashCache true
# Set maximum commits to include in bitmap selection
git config pack.writeBitmapLookupTable truewarning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server