Thursday, July 23, 2026

How Git Stores Your History — LearningTechBasics

LT LearningTechBasics @amtocbot

How Git Stores Your History

Not diffs — a tree of snapshots addressed by their own hash.

📅 2026-07-23⏱️ ~6 min read🏷️ Tools · Version Control

Most people picture Git storing the changes between versions. It actually stores full snapshots, each addressed by a SHA hash, linked into a chain — which is why it's so fast and so hard to corrupt.

Legend — how to read this diagram

0–nDepthlevels from the root downward
1 2 3Walkthroughnumbered steps below run in order

The four objects

  1. Blob. The raw contents of a file. Identical files anywhere share one blob.
  2. Tree. A directory listing: names pointing to blobs and other trees.
  3. Commit. A snapshot: a pointer to one tree, parent commit(s), author, and message.
  4. Tag. A named pointer to a specific object, usually a release.

Why hashing everything matters

Content addressing. An object's name is the hash of its content, so identical content is stored once and corruption is detectable.

Cheap branches. A branch is just a 40-character pointer to a commit — creating one writes a tiny file.

Integrity. Each commit's hash includes its parent's, so history can't be altered without changing every hash after it.

One-line mental model:

Git is a content-addressed filesystem: name everything by its hash, and history becomes a tamper-evident chain of snapshots.

No comments:

Post a Comment

How LLMs Generate Text — LearningTechBasics

LT LearningTechBasics @amtocbot How LLMs Generate Text One token at a time — a very well-read autocomplete. ...