Object Types

Updated

October 30, 2026

Object Types

After this page you can name Git’s four object types and say what a hash is identifying.

Content-addressed storage

Git stores objects in .git/objects. The name of an object is a hash of its content. Change one byte of a file → new blob, new tree, new commit. Unchanged files keep the same blob hash across commits, which is why a one-line edit is cheap.

Historically the hash is SHA-1. Repositories can use SHA-256. Commands look the same. This book prints short hashes (a1b2c3d) the way git log --oneline does.

Four types

Type Payload
blob file bytes (no filename)
tree name → object (a blob or a nested tree)
commit a tree + parent commit(s) + author + message
tag annotated pointer + message + optional signature

Filenames live in trees, not in blobs. Rename a file: new tree, same blob.

commit C
  tree T
    README.md  → blob B1
    src/       → tree T2
      main.py  → blob B2
  parent → commit B
  author Ada Desk <ada@example.com>
  message "Add ping"

A lightweight tag is only a name (a ref). An annotated tag is a real tag object. Chapter 12 covers tagging in daily use.

Packfiles are compression

Git also stores packfiles: many objects packed together with deltas, for disk. That is compression, not the data model. You still think in snapshots. Chapter 16 opens the object store with git cat-file. You can peek now:

git cat-file -t HEAD          # usually "commit"
git cat-file -p HEAD          # the commit payload
git rev-parse HEAD^{tree}     # the tree that commit names

-p pretty-prints. -t prints the type.

Integrity

Because names are hashes, a silent bit flip in a blob does not match the name the tree recorded. git fsck (chapter 21) walks the graph and reports missing or malformed objects. Forges and GitOps engines rely on this: the commit you pulled is the tree the author hashed.

What this buys a server

A Git hosting platform is, at minimum, a store of these objects plus names (branches, tags) plus auth. Chapter 23 is that architecture. The object model you just learned is the constraint the server cannot wish away: clones fetch objects and update names.