Git: The Model
The model under the commands
Git is a small idea wearing a large interface. Underneath is a store of objects named by a hash of their own contents, three trees, and some files holding one name each. Learn those and the commands stop being spells: you can say what each one will move before you press return.
- Modules
- 6
- Drills
- 9
- Build steps
- 6
- Time
- ~5h
Walk out able to
Predict what a command does to each of the three trees, say which commits it orphaned, and get back work you destroyed on purpose.
What you will be able to read
Objects, trees, the index
What a commit stores, and what it costs to change one file.
Every name for a commit
Branches, HEAD, detached HEAD, ranges, and the ~ ^ walk.
Reset, revert, merge, rebase
Which trees each one moves, and the graph it leaves.
Reachability and recovery
What went unnamed, where the reflog holds it, how long for.
The pitch
What you practise, and what you leave with
A repository built with plumbing commands, destroyed with reset --hard, and recovered from the reflog — with proof the tree came back identical.
You will practise
- Count the objects a commit really adds
- Write HEAD~2, main..side and the rest
- Pick a reset mode by the trees it moves
- Say what a pointer move orphaned
Afterwards you can
- Predict what git status will say
- Read the graph a merge or rebase leaves
- Choose soft, mixed, hard or revert
- Recover a branch you destroyed
Modules
6 modules, 34 items
Lessons explain one idea. Drills repeat it until it sticks. Build steps make something that exists afterwards.
- 1
Objects, not diffs
~53 minSay what Git writes down when a file changes, and produce an object name yourself.
- LessonWhy the model is worth an hour5 min
- LessonThree kinds of object6 min
- LessonWhere an object’s name comes from7 min
- LessonWhat one changed line costs6 min
- Build stepMake a commit without git commit18 min
- DrillCount what the store gained11 min
- 2
The three trees
~46 minPredict what git status will say before you run it, because you know what it compares.
- LessonThree trees, and what fills each7 min
- LessonRead status as two comparisons7 min
- LessonEvery command as a copy7 min
- Build stepAsk the index what it is holding13 min
- DrillSay what status will print12 min
- 3
Names for a commit
~57 minOpen .git and explain every pointer in it, then walk to any commit without guessing.
- LessonA branch is a file with a name in it7 min
- LessonWhen HEAD names a commit directly6 min
- LessonThe notation for naming a commit9 min
- Build stepRead the pointers with cat11 min
- DrillWalk to the commit it names11 min
- DrillWrite the expression, do not decode it13 min
- 4
Moving the pointer on purpose
~48 minPick an undo by naming the trees it moves, and know when to append instead.
- LessonUndo, and which trees it touches9 min
- LessonRewrite a name, or add a commit6 min
- LessonThe same commands, aimed at one file6 min
- DrillName the command for the intention12 min
- Build stepUndo the same commit four ways15 min
- 5
Two lines, one graph
~49 minDraw the graph a merge leaves and the one a rebase leaves, and say what changed names.
- LessonWhat a merge leaves behind8 min
- LessonThe merge that creates nothing6 min
- LessonA rebase is a copy and an abandonment8 min
- DrillCount the graph a move leaves12 min
- Build stepMake both shapes and compare them15 min
- 6
Reachable, and everything else
~1hSay what a pointer move left unnamed, find it again, and get it back under a branch.
- LessonUnnamed is not the same as deleted7 min
- LessonA second set of roots6 min
- LessonWhat actually deletes, and the one loss7 min
- DrillSay what went unnamed12 min
- DrillFind the state you want back12 min
- DrillDecide what may be committed10 min
- Build stepLose two commits and get them back22 min
A taste of the code
hello$ git hash-object -w -- note.txt
ce013625030ba8dba906f756967f9e9ca394464a
More in Tools & workflow
Keep going
Regex
Read the pattern. Then predict exactly what it does.
Intermediate~4h6 modules
Git: Collaboration
Two people, one history, and no surprises.
Intermediate~5h7 modules
VS Code
Stop guessing what the window just did.
Foundational~4h6 modules
JSON & YAML
Two formats you can read. Neither one means what you think.
Intermediate~4h5 modules
Stop memorising the commands. Learn what they move.
The first item is free. ~5h of focused work, at your own pace.
Intermediate~5h6 modules