Skip to content
Latchkey

git repack: Usage, Options & Common CI Errors

git repack consolidates a repository’s objects into fewer, more efficient packfiles.

Repacking shrinks a bloated repo and speeds up object access. The common -a -d combination rewrites everything into one pack and removes the now-redundant ones.

What it does

git repack creates new packfiles from existing objects, optionally folding all packs into one and deleting the originals, improving delta compression and lookup speed.

Common usage

Terminal
git repack -a -d
git repack -A -d                # keep unreachable objects loose
git repack -a -d --depth=50 --window=250
git repack -d -l                # local objects only

Options

FlagWhat it does
-aPack all objects into a single pack
-ALike -a but keep unreachable objects loose
-dDelete redundant packs afterward
--depth / --windowTune delta compression
-lPack only local objects (skip alternates)

Common errors in CI

fatal: Out of memory during delta compression on huge repos - lower --window/--depth or pack.threads, and ensure enough free disk for the new pack to be written before the old ones are deleted. Running repack -d while another git process reads the repo can race; serialize it.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →