Version Control as a Graph of Commits
A repository is a graph: each commit is a snapshot that points at the one it came from, and a branch is a movable label on a node. Once the shape is clear, most version control commands stop being incantations and become moves on that graph.
What a learner can do afterwards
- Draw the commit graph of a short history and mark where each branch label sits
- Say what changes in the graph when a commit is made and when a branch is created
- Explain what a detached head means in terms of the labels
1 · Read
Each commit is a snapshot that points at its parent. Those links form a graph of history. A branch is only a movable label stuck on one node, and HEAD marks which label you stand on.
Start with commit A, then B, then C, while main moves A to B to C. Create a branch named feature at C and no node is added: a second label just lands on C. Commit D on feature and only feature slides to D, while main stays on C.
Check out an old commit directly and HEAD points at a node with no branch label. That is a detached head. New commits there grow with no label to hold them, so switching away can strand them.
Read every command as a graph move. Commit adds a node and slides your label, branch adds a label, checkout moves HEAD. Name the moved labels before you run anything.
Commits link into a graph, branches label nodes, and HEAD marks where you stand.
2 · Watch
Take it off screen
Where it sits
8 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.