P-2.3 Version Control: Commits, History and Undo
You can put a project under version control, record meaningful commits, read the history, see exactly what changed, and recover a previous state without losing work.
Version control is the single highest-value tool a programmer learns, and it is usually taught as four commands to memorise. What it actually gives you is the ability to experiment without fear, because any state you recorded can be recovered exactly. The mental model to get right early is that a commit is a snapshot of the whole project rather than a diff, which makes almost everything else follow.
Work through these
A repository, a commit, and why a commit is a snapshot
Recording a commit stores the state of every file at that moment, and the differences you see are computed between snapshots rather than stored. Once that lands, moving around history stops feeling dangerous.
Pro Git (2nd edition) · ReferenceThe staging area: choosing what goes into the next commit
Changes are selected before they are recorded, which lets one messy afternoon become three commits that each do one thing. This is the step most people skip and later wish they had not.
Writing a commit message that is worth reading in a year
The message explains why the change was made, because the code already shows what changed. A history of messages saying update is a history nobody can use.
Reading history: what changed, when, and by whom
Being able to find the change that introduced a behaviour turns a mysterious defect into a dated, attributed, reviewable event. This is the payoff for every message you wrote carefully.
Undoing safely: restoring a file, moving back, and what is recoverable
Almost everything recorded can be recovered, and the small number of operations that genuinely discard work are worth knowing by name before you need them.
Sign in to keep your progress.
Free resources
Links last checked 31 Aug 2026.
Stuck here?
Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.
Checking your session…
Topics shown in module order.