Git multi-pack index quick reference¶
Essential commands¶
| Task | Command |
|---|---|
| Write multi-pack index | git multi-pack-index write |
| Write MIDX with reachability bitmaps | git multi-pack-index write --bitmap |
| Set preferred pack for bitmaps | git multi-pack-index write --bitmap --preferred-pack=pack-<sha>.pack |
| Verify MIDX integrity | git multi-pack-index verify |
| Batch repack small packs (e.g. under 64MB) | git multi-pack-index repack --batch-size=64M |
| Expire and delete redundant packs | git multi-pack-index expire |
| Geometric repack with MIDX generation | git repack --geometric=2 -d --write-midx |
| Check pack and MIDX status | ls -lh .git/objects/pack/ |
Recommended configuration¶
# Enable MIDX support (default in modern Git)
git config core.multiPackIndex true
# Write reverse indexes for fast pack lookups
git config pack.writeReverseIndex true
# Cache object hashes in bitmaps
git config pack.writeBitmapHashCache true
CI maintenance pipeline snippet¶
Add this step to your runner maintenance cron or pipeline cleanup stage:
#!/usr/bin/env bash
set -euo pipefail
# Compact small packs without rewriting large historical packs
git multi-pack-index repack --batch-size=128M
# Remove obsolete packfiles
git multi-pack-index expire
# Update MIDX and generate reachability bitmaps
git multi-pack-index write --bitmap
# Validate index against pack checksums
git multi-pack-index verify
Troubleshooting¶
Corruption detected during verification¶
If git multi-pack-index verify returns non-zero:
# Remove corrupted MIDX file
rm -f .git/objects/pack/multi-pack-index*
# Rebuild clean MIDX from existing packfiles
git multi-pack-index write --bitmap
Bitmaps not generating¶
If --bitmap outputs a warning or fails:
- Ensure the repository has at least one packfile. Loose objects are not indexed in bitmaps.
- Run
git repack -dorgit multi-pack-index repack --batch-size=0to convert loose objects into packs first. - Re-run
git multi-pack-index write --bitmap.