Home > Positioning > Subjects > Git > The object model

The object model

At its core Git is a content-addressable store: a key–value database in which the key of every object is the hash of its content. Four object types build everything else.

Because an object’s name is the hash of its content, objects are immutable — any change produces a different object with a different name — and identical content is automatically de-duplicated. The same property makes integrity intrinsic: a commit’s hash depends on its tree and parents, so it transitively fixes the whole history behind it. Objects are stored zlib-compressed under .git/objects/, and bundled into packfiles for transport and storage.

The index

Between the working files and the object store sits the index (the staging area): a mutable description of what the next commit will contain. git add records content into the index; committing turns the index into a tree and a commit. The index is what lets a commit be composed deliberately rather than capturing the working directory wholesale.

Hashing: SHA-1 to SHA-256

Git originally named objects by SHA-1 — chosen, in Torvalds’ account, mainly to guard against accidental corruption rather than as a security measure. After the 2017 SHAttered demonstration of a practical SHA-1 collision, Git adopted a collision-detecting SHA-1 variant, and a transition to SHA-256 has been specified; as of 2026 it is available but not the default, and most repositories remain on SHA-1.

For the byte-level details, see the Git Internals chapter of Pro Git.

Sources