intermediate · 27 minute study
Branches are names that move through a graph
Reason about diverging work and merging without assuming a branch is a separate folder or that every merge creates the same history shape.
Useful preparation · 1 prerequisite
Use this as a map, not a lock. If these ideas are familiar, continue.
- The commit records the index, not everything in your editor — Create focused commits without accidentally publishing unfinished edits or assuming that saved files are already part of a commit.
First, build a mental model
A commit records a snapshot and parent links. A branch is a movable name pointing at a commit. HEAD normally identifies the checked-out branch; detached HEAD points directly at a commit.
- Creating a branch at the current commit creates another name at that position, not a full copy of every file.
- New commits advance the checked-out branch; other branch names stay where they were.
- A fast-forward moves a branch name to a descendant when no divergent merge is required.
- A merge of divergent histories usually creates a commit with both histories as parents, after content is reconciled.
- Fetch updates remote-tracking information without automatically merging it into the checked-out branch. Inspect ancestry before choosing the next operation.
# Start with main pointing at a known commit.
git switch -c feature/score-label
# Make one focused change, inspect it and commit it.
git log --oneline --decorate --all
git switch main
# If main has not moved and is an ancestor of the feature:
git merge --ff-only feature/score-label
# --ff-only refuses if a fast-forward is not possible.- New branch
main and feature initially name the same commit.
- Feature commit
Only feature advances while it is checked out.
- Fast-forward
If ancestry permits it, main can move to the feature commit without creating a merge commit.
Production thinking
Take this beyond the example.
Use graph inspection to understand what is local, what is shared and what changed upstream. Never treat a familiar branch name as proof that its content is still the version you reviewed.
Sources and further reading
Your evidence
unseen is a local learning signal, not a credential or proof of production competence.
Explain the mental model, then explicitly acknowledge it. Opening a page is not evidence.
Supported retries can complete this lesson. Independent evidence and delayed review determine the skill stage.
Next lesson · Resolve the intended behavior, not just the markers →