Skip to content
rajin

26Packfiles and delta compression

advanced25–30 minHandbook pp. 57–58 Not started

Warm-up · from “Team collaboration and safe force-pushing”

What does a lease check?

No notes: write what you remember, then check. Recalling before reading is what makes it stick.

The problem

A repository has hundreds of versions of a large text file. Why does its object database not necessarily grow by the full file size each time?

After this lesson you can

  • Distinguish loose and packed storage.

  • Inspect a pack index.

  • Explain delta chains without confusing them with history.

Key terms

Full glossary

Say what each term means, then open it to check.

  • Packfile · new in this lesson

    Compact representation of many Git objects, possibly using deltas.

  • Commit · from lesson 7

    Object identifying a root tree, parent(s), metadata and message.

  • Object ID · from lesson 5

    Hash-based identity of a serialized Git object.

Visual mental model

  1. Loose objects
  2. Pack encoding
  3. Pack + index
  4. Object by ID

Build the mental model

Loose objects store individually compressed object payloads. Packing stores many objects in a packfile, sometimes representing an object as a delta relative to another object. Delta encoding can reduce repeated content; the choice of base and chain depends on heuristics, configuration and object characteristics. Git does not guarantee that the newest version is always the base. Object IDs and logical snapshot semantics remain unchanged.

Computed in your browser · exactIdentity is independent of storage

Computed in your browser: packing changes the encoding on disk, never these IDs.

Under the hood

A .pack contains packed object data; an accompanying .idx maps object IDs to locations so Git can find objects efficiently. git verify-pack -v reports types, sizes, offsets and, for deltified objects, chain depth and base ID. Git may also produce other auxiliary files. git gc and repack can consolidate storage; network transfers may use packs. Do not manipulate packed files manually.

Common mistake · important nuance

A delta base is a storage relationship, not necessarily a commit parent or the preceding file version.

Move between parts freely. Completion counts only what you verify and answer.