Interview Prep/Git & GitHub/Git internals: objects, refs and the index

How do packfile delta chains work and what controls them?

AdvancedConceptGit internals: objects, refs and the index
Answer

Inside a pack, an object is either stored whole or as a delta against another object (OFS_DELTA by offset or REF_DELTA by ID). Git sorts candidates by type, name and size to find good bases, and chains can be up to pack.depth deep (default 50) within a pack.window of candidates (default 10). Deeper or wider settings shrink the pack at the cost of CPU on repack and slower reads.

git repack -adf --depth=250 --window=250
git verify-pack -v .git/objects/pack/*.idx | head
All Git & GitHub questions Roadmap: Git & GitHub

More on Git internals: objects, refs and the index