git-repack
Pack Git objects to reduce repository size
TLDR
Pack unpacked objects in the current directory
Remove redundant objects after packing
Repack all objects into a single pack
Limit the repack to local objects only
SYNOPSIS
git repack [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-m] [--window=<n>] [--depth=<n>] [--window-memory=<n>] [--max-pack-size=<n>] [--no-reuse-delta] [--no-reuse-object] [--compression-level=<n>] [--threads=<n>] [<ref-list>]
PARAMETERS
-a, --all
Pack all loose objects reachable from any reference into a pack (default for git gc)
-A
Like -a, but also pack unreachable loose objects (used internally by git gc)
-d
After packing, remove any packfiles or loose objects not needed by refs in <ref-list>
-f
Pass -f to git-pack-objects (drop redundant objects)
-F
Pass -F to git-pack-objects (drop redundant objects after verification)
-l
Pass --local to git-pack-objects (ignore borrowed objects)
-n
Do not update the server information with git update-server-info
-q
Pass -q to git-pack-objects (quiet mode)
-m
Use the multi-threaded git pack-objects (experimental)
--window=<n>
Limit window for delta compression to <n> objects (default 10)
--depth=<n>
Maximum delta depth (default 50)
--window-memory=<n>
Maximum memory for delta window (default 0 = unlimited)
--max-pack-size=<n>
Maximum packfile size in bytes
--no-reuse-delta
Do not reuse existing deltas
--no-reuse-object
Do not reuse existing objects
--compression-level=<n>
Zlib compression level (-1=auto, 0=none, 9=best)
--threads=<n>
Number of threads to use (default 1)
DESCRIPTION
git-repack is a Git plumbing command that reorganizes objects in a repository by packing loose objects and repacking existing packfiles into more efficient structures. Loose objects are individual files stored uncompressed, while packfiles use delta compression to minimize disk usage and speed up operations like cloning and fetching.
By default, it packs only loose objects reachable from the current refs into new packfiles and removes the originals. This reduces repository size and improves performance. Options allow controlling the scope (e.g., all refs), delta compression parameters, and cleanup.
It runs git pack-objects internally and is invoked automatically by git gc during garbage collection. Manual use is useful after many small commits creating loose objects or when packfiles become fragmented. Repacking a large repo can be CPU- and I/O-intensive, so consider running it during low activity.
Supports multi-threading for faster packing on modern hardware.
CAVEATS
Intensive on large repos; run on bare repos or during idle times. Locks repository during execution. Avoid on shared repos without coordination. -d aggressively prunes; backup first.
REF-LIST ARGUMENT
Optional list of references to limit repacking scope, e.g., refs/heads/master refs/tags/v1.0. Omitting packs all.
INVOCATION CONTEXT
git gc calls it with -a -d -f -q by default for maintenance.
Use git gc --aggressive for deeper repacks.
HISTORY
Part of Git since v1.5.0 (2007). Gained multi-threading support in Git 2.10 (2016). Ongoing optimizations for delta compression and parallelism in recent versions.
SEE ALSO
git-gc(1), git-pack-objects(1), git-prune-packed(1), git-fsck(1)


