The set operation problem
Operations like clone, fetch, and gc need to compute "what objects are reachable from these commits?" — a graph traversal that touches every reachable object. Reachability bitmaps store this answer as compressed bitmaps, turning the traversal into bitwise OR/AND operations.
Generating
git repack -adb
git multi-pack-index write --bitmap
git config repack.writeBitmaps true
git config pack.writeBitmaps true
The -b flag to repack writes a bitmap alongside the new pack. The MIDX form (Git 2.34+) writes a bitmap for the multi-pack-index instead.
How servers use them
When a client clones, the server must enumerate all reachable objects. With bitmaps, this is one OR over the bitmaps of all branch tips. Negotiation during fetch ("what do I have, what do you have?") similarly accelerates from minutes to milliseconds on large repos.
Pseudo-merge bitmaps (Git 2.45+)
Recent Git supports synthesizing a "pseudo-merge" bitmap that approximates the OR of many real bitmaps, useful when the working set of refs is enormous. Configure with:
git config pack.writeBitmapPseudoMergeStable true
git config repack.writeBitmapHashCache true
Verifying
ls .git/objects/pack/*.bitmap
git rev-list --use-bitmap-index --count --all
git rev-list --test-bitmap HEAD
--test-bitmap reports whether bitmaps are consistent with a real walk.
Server vs client
Bitmaps benefit both sides but matter most on the server, where they reduce CPU per clone. Clients benefit from git clone times dropping and from local git rev-list --count --all queries used by tools like LSP servers.
Common mistakes
Writing bitmaps every gc on small repos — overhead may exceed benefit. Forgetting that bitmaps cover only objects in one pack (or the MIDX); split repos must use MIDX bitmaps. Mixing pack-level and MIDX-level bitmaps; pick one strategy.
Real numbers
GitHub reported 50-90% reductions in clone CPU after enabling bitmaps. GitLab Geo replication times dropped from hours to minutes on large repos. For self-hosted setups, bitmaps are usually the single highest-leverage perf change after MIDX.
Related
See "Multi-pack-index (MIDX): unified pack object lookup" and "Geometric repacking strategy".