Turns hundreds of loose ref files into one. fsck-friendly.
git pack-refs collapses loose ref files (.git/refs/heads/foo, .git/refs/tags/v1, ...) into a single packed-refs file. On a repo with thousands of refs, this is the difference between snappy and molasses.
Refs are normally one tiny file per ref. pack-refs is the same idea as packing objects: trade many syscalls for one. Git transparently reads from either location.
git pack-refs [--all] [--no-prune] [--auto]| Flag | What it does |
|---|---|
--all | Pack all refs, not just tags. You almost always want this. |
--no-prune | Keep loose refs after packing. Default is to delete them. |
--prune | (Default) delete loose refs once packed. Saves the inodes. |
--auto | (Git 2.34+) Pack only if heuristics say it's worth it. What gc uses. |
--no-prune | ⚠️ Doubles disk usage for refs and is rarely what you want outside of debugging. |
ls-remote or shell tab-completion..git directory — fewer files, smaller archive.git pack-refs --allgc runs internallygit pack-refs --all --prunecat .git/packed-refsgit pack-refs --all --no-prunegit gc handles it. Reach for it when you've imported a swarm of refs.git gc --auto rather than pack-refs directly; the heuristics are usually right..git/refs/heads/ may be nearly empty — that's fine. git show-ref still works.pack-refs aren't magically packed..git/refs/... directly may break — always use git for-each-ref.packed-refs is a flat text file; editing it by hand is asking for trouble. Use git update-ref / git pack-refs.Hit each option, then Check answers. Score is recorded; Next is always open.