Loose objects in, packfiles out.
git repack consolidates loose objects and existing packfiles into fewer, denser packs. It's the heavy lifter that git gc calls under the hood.
Loose objects are one file per object — fast to write, slow to read at scale. Packs are delta-compressed archives with an index. Repack trades CPU now for I/O savings forever.
git repack [-a] [-A] [-d] [-l] [-f]
[--max-pack-size=<n>] [--depth=<n>] [--window=<n>]
[--keep-pack=<name>] [--write-bitmap-index]| Flag | What it does |
|---|---|
-a | Pack all reachable objects into a single new pack. Without this, you only repack loose objects. |
-A | Like -a but unreachable objects are exploded back to loose instead of dropped — gives gc a chance to expire them. |
-d | Delete redundant packs after repacking. Without -d you accumulate cruft. |
-l | Use only local packs; skip alternates. Important when working with shared object stores. |
--max-pack-size=<n> | Cap pack file size (e.g. 2g). Useful for filesystems that hate huge files. |
--depth=<n> | Max delta chain length. Default 50; larger = smaller packs, slower reads. |
--window=<n> | How many neighboring objects to consider for delta candidates. Default 10; larger = better compression, slower repack. |
--write-bitmap-index | Generate a .bitmap file. Massive speedup for clone and fetch on the server side. |
-f | ⚠️ Force re-deltification of all objects. Throws away existing deltas — only use after changing --depth/--window. |
repack -adf --write-bitmap-index for clone performance.filter-repo..git/objects/ has thousands of loose files slowing every command.git repack -adgit repack -adf --write-bitmap-index --depth=50 --window=250git repack -adlgit repack -ad --max-pack-size=2g-ad is the everyday shortcut: pack everything, drop redundant packs. Memorize it.--write-bitmap-index is non-negotiable — it can cut clone time by 10x.repack while another writer is active; you can race against pushes and end up with dangling refs to repacked objects.-d, your old packs stay around as cruft. Disk usage grows, doesn't shrink.-A (capital) keeps unreachable objects as loose so gc can expire them; -a (lower) just packs what's reachable. They're not interchangeable.--window and --depth for tighter packs costs CPU every read, not just at repack time.Hit each option, then Check answers. Score is recorded; Next is always open.