Git#

Most people learn Git as a list of incantations: add, commit, push, and a memorised spell for when something goes wrong. That works right up until the day it doesn't, because the commands only make sense once you can see the data structure underneath them. This page teaches the structure first — three trees, a graph of immutable snapshots, and a handful of pointers — and then shows every command as a move on that structure. Each mechanism is an animation: press Play, then walk it with the arrow buttons and read the note under each step. Code examples use the Shell tab by default; where a config file or a script is the better answer, the other tabs hold it.

Three ideas carry almost all of Git. Everything is content-addressed — an object's name is the hash of what is inside it, so nothing can be modified, only added. A commit is a full snapshot plus a pointer to its parent — history is a graph of snapshots, and diffs are computed on demand, never stored. And a branch is a 41-byte file holding one commit id — so branching, merging and “moving” work are all just writing a different id into a small file. Hold those three and the command list stops being arbitrary.

14 Topics • Mental Models, Interactive Animations & Worked Questions
Unit 1

How Git Thinks#

The mental model: three trees, snapshot commits and branches that are just pointers.

Unit 2

Everyday Work#

The daily loop: stage deliberately, read what changed, and undo safely.

Unit 3

Branching, Merging & Rewriting History#

Combining lines of work, resolving conflicts and reshaping history before anyone else sees it.

Unit 4

Collaboration & Recovery#

Sharing work through remotes, and getting out of trouble when things go wrong.