Optimize a Repository With git repack
Consolidate loose objects into a compact packfile.
Run git repack -ad to rewrite packs and drop redundant loose objects.
01Command
Command
$ git repack -ad02What it does
Repositories accumulate loose objects and duplicate packs; repacking consolidates them, reducing disk use and speeding up fetch and clone. It is a routine maintenance task that is easy to script across many repositories, unlike a single-repo GUI button.
03Risk
!Warning: Run it when no other git process is writing; concurrent operations can race with repacking.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- git-repack documentationEvidence: Documents git repack and options such as -a and -d.
Last verified: 2026-10-13 · Category: Developer