Git for EngineersGit Internals

Git Internals

Blobs, trees, commits, and refs — how Git actually stores data.

~25 min read

Git Internals

Git is a content-addressable filesystem with a VCS on top.

Object types

  • blob: file contents
  • tree: directory listing (maps names to blobs/trees)
  • commit: snapshot (points to a tree + parent commits + metadata)
  • tag: named commit

How commits work

git cat-file -t HEAD     # commit
git cat-file -p HEAD     # see the commit object
git cat-file -p HEAD^{tree}  # see the tree

Everything is hashed with SHA-1. If two files have the same content, they share one blob.