Chapter One

Foundations

The mental model behind Git — history as a graph of immutable, content-addressed snapshots — plus what version control is for, how to configure Git correctly, and the three trees every command moves content between.

4 topics

Git has a reputation for being confusing, and most of that confusion comes from learning the commands before the model they operate on. This chapter installs the model first: what a version control system actually guarantees, and the handful of ideas — snapshots, content addressing, the commit graph, and the three trees — that make every later command predictable.

Get these four topics right and the rest of the course compounds. Branching, rebasing, the object model, even GitHub and Actions all rest on knowing that Git stores immutable snapshots by hash and that add, commit, and reset simply move content between the working tree, the index, and HEAD.

The three trees, and the commands that move content between them
Working treefiles on disk
Indexgit add
HEADgit commit

Undo runs the other way: git restore pulls HEAD or the index back over the working tree; git reset moves HEAD and, with --hard, all three.

Topics in This Chapter