Git Reference ยท Maintenance and Recovery
git repack command
Reference for git repack: -a, -d, -l, --cruft, --geometric, bitmaps and delta options. Learn how Git consolidates loose objects and packs into fewer, smaller packfiles.
git repack packs objects into packfiles. A packfile stores many objects in one file, compressing similar ones as deltas against each other, and has an index for fast lookup. A fresh repository holds one small file per object; over time, packing makes the repository much smaller and faster to read and transfer.
Most of the time, git gc calls repack for you. Direct use is for fine control: consolidating packs after many fetches, making a pack for a bare server repository with bitmaps, or tuning delta compression.
git repack [-a] [-A] [-d] [-l] [-f] [-F] [-q] [-b] [-m] [--window=<n>] [--depth=<n>] [--cruft] [--geometric=<factor>]
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
| Option | Description |
|---|---|
-a |
Pack everything reachable into a single new pack (existing packs are rewritten). Without -a, only loose objects are packed into an incremental pack. |
-A |
Like -a, but unreachable objects in old packs are turned loose instead of dropped (so gc can expire them later). |
-d |
After packing, delete redundant packs and run git prune-packed to remove loose duplicates. |
-l |
Pass --local: ignore objects borrowed from alternates. |
-f |
Recompute all deltas from scratch (--no-reuse-delta). |
-F |
Recompute every object's compression, not only deltas (--no-reuse-object). |
--window=<n>, --depth=<n> |
How many neighbors to try as delta bases (default 10) and the maximum delta chain length (default 50). |
--window-memory=<n>, --max-pack-size=<n> |
Limit memory and the size of each output pack. |
-b, --write-bitmap-index |
Write a reachability bitmap; speeds clone and fetch on servers. Needs -a. |
-m, --write-midx |
Write a multi-pack index. |
--cruft |
Store unreachable objects in a separate cruft pack instead of loose files. |
--geometric=<factor> |
Keep pack sizes in a geometric progression, rewriting only the small ones. Good for frequent background maintenance. |
--keep-pack=<name> |
Leave a named pack alone. A .keep file next to a pack does the same. |
--unpack-unreachable=<when> |
Loosen unreachable objects younger than the date. |
-q, --quiet |
No progress. |
Usage notes
- Why packs are small. A pack stores a later version of a file as a delta against an earlier version.
--windowand--depthtrade time and memory for size; the defaults suit most repositories. -a -dis the classic "full repack". It is cheap on small repositories and heavy on large ones, since it rewrites everything.- Keep files.
git clone --local,receive-packandindex-pack --keepcreate.keepfiles to protect packs while refs are updated. Remove stale ones if you know the process is dead. - Safety of
-d. Packs are deleted only after the new pack is written and indexed. - Server repositories benefit from
-b(bitmaps),-mand--geometric, and fromrepack.writeBitmaps,repack.useDeltaIslandsandpack.*settings. - Unreachable objects in packs are dropped by
-a -d, which can discard commits that were only held by the reflog if the reflog has already expired; prefer-Aor--cruftwhen unsure. - Alternates:
-lmakes a repository stand alone from the objects it borrows.