| GIT-REPACK(1) | Git Manual | GIT-REPACK(1) |
NAME
git-repack - Pack unpacked objects in a repository
SYNOPSIS
git repack [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-b] [-m]
[--window=<n>] [--depth=<n>] [--threads=<n>] [--keep-pack=<pack-name>]
[--write-midx[=<mode>]] [--name-hash-version=<n>] [--path-walk]
[--filter=<filter-spec>] [--drop-filtered [--dry-run]]
DESCRIPTION
This command is used to combine all objects that do not currently reside in a "pack", into a pack. It can also be used to re-organize existing packs into a single, more efficient pack.
A pack is a collection of objects, individually compressed, with delta compression applied, stored in a single file, with an associated index file.
Packs are used to reduce the load on mirror systems, backup engines, disk storage, etc.
OPTIONS
-a
Note that users fetching over dumb protocols will have to fetch the whole new pack in order to get any contained object, no matter how many other objects in that pack they already have locally.
Promisor packfiles are repacked separately: if there are packfiles that have an associated ".promisor" file, these packfiles will be repacked into another separate pack, and an empty ".promisor" file corresponding to the new separate pack will be written.
-A
-d
--cruft
--cruft-expiration=<approxidate>
--max-cruft-size=<n>
--combine-cruft-below-size=<n>
--expire-to=<dir>
-l
-f
-F
-q, --quiet
-n
--window=<n>, --depth=<n>
The default value for --window is 10 and --depth is 50. The maximum depth is 4095.
--threads=<n>
--window-memory=<n>
--max-pack-size=<n>
--filter=<filter-spec>
--filter-to=<dir>
--drop-filtered
Only large blobs are supported for now, so --filter=blob:limit=<n> is currently the only accepted filter. Because dropped objects must be recoverable, this option requires a promisor remote to be configured and refuses to run otherwise.
This option requires -a, and implies -d: the objects are dropped by rebuilding the promisor pack without them and then removing the now redundant old packs, so the redundant packs must be deleted for the space to actually be reclaimed. It is incompatible with --filter-to and with bitmap writing (-b/--write-bitmap-index), since filtering breaks the single-pack closure that bitmaps require. A bitmap setting coming from configuration is silently disabled for the duration of the command.
As a convenience, since dropped objects remain recoverable by lazy fetch, --drop-filtered refuses to run while another operation (merge, rebase, am, cherry-pick, revert, or bisect) is in progress, to avoid a surprising network fetch mid-operation, and refuses to drop any blob that the current index references, since such a blob would only be lazily re-fetched by the next command that inspects the working tree. These checks are skipped in bare repositories, which have neither a working tree nor an index.
--dry-run
-b, --write-bitmap-index
--pack-kept-objects
--keep-pack=<pack-name>
--unpack-unreachable=<when>
-k, --keep-unreachable
-i, --delta-islands
-g<factor>, --geometric=<factor>
git repack ensures this by determining a "cut" of packfiles that need to be repacked into one in order to ensure a geometric progression. It picks the smallest set of packfiles such that as many of the larger packfiles (by count of objects contained in that pack) may be left intact.
Unlike other repack modes, the set of objects to pack is determined uniquely by the set of packs being "rolled-up"; in other words, the packs determined to need to be combined in order to restore a geometric progression.
Loose objects are implicitly included in this "roll-up", without respect to their reachability. This is subject to change in the future.
When writing a multi-pack bitmap, git repack selects the largest resulting pack as the preferred pack for object selection by the MIDX (see git-multi-pack-index(1)).
-m, --write-midx[=<mode>]
default
incremental
Without --geometric, a new MIDX layer is appended to the existing chain (or a new chain is started) containing whatever packs were written by the repack. Existing layers are preserved as-is.
When combined with --geometric, the incremental mode maintains a chain of MIDX layers that is compacted over time using a geometric merging strategy. Each repack creates a new tip layer containing the newly written pack(s). Adjacent layers are then merged whenever the newer layer’s object count exceeds 1/repack.midxSplitFactor of the next deeper layer’s count. Layers that do not meet this condition are retained as-is.
The result is that newer (tip) layers tend to contain many small packs with relatively few objects, while older (deeper) layers contain fewer, larger packs covering more objects. Because compaction is driven by the tip of the chain, newer layers are also rewritten more frequently than older ones, which are only touched when enough objects have accumulated to justify merging into them. This keeps the total number of layers logarithmic relative to the total number of objects.
Only packs in the tip MIDX layer are considered as candidates for the geometric repack; packs in deeper layers are left untouched. If the tip layer contains fewer packs than repack.midxNewLayerThreshold, those packs are excluded from the geometry entirely, and a new layer is created for any new pack(s) without disturbing the existing chain.
--name-hash-version=<n>
--path-walk
CONFIGURATION
Various configuration variables affect packing, see git-config(1) (search for "pack" and "delta").
By default, the command passes --delta-base-offset option to git pack-objects; this typically results in slightly smaller packs, but the generated packs are incompatible with versions of Git older than version 1.4.4. If you need to share your repository with such ancient Git versions, either directly or via the dumb http protocol, then you need to set the configuration variable repack.UseDeltaBaseOffset to "false" and repack. Access from old Git versions over the native protocol is unaffected by this option as the conversion is performed on the fly as needed in that case.
Delta compression is not used on objects larger than the core.bigFileThreshold configuration variable and on files with the attribute delta set to false.
SEE ALSO
GIT
Part of the git(1) suite
| 2026-09-27 | Git 2.56.0 |