Skip to content
rajin

15Tags and revision syntax

core25–30 minHandbook pp. 35–36 Not started

Warm-up · from “HEAD and detached HEAD”

What moves in detached HEAD when committing?

No notes: write what you remember, then check. Recalling before reading is what makes it stick.

The problem

You need to inspect an old release, find the second parent of a merge, and compare branches. Learn to express each selection precisely.

After this lesson you can

  • Distinguish lightweight and annotated tags.

  • Navigate parents.

  • Interpret log ranges versus diff ranges.

Key terms

Full glossary

Say what each term means, then open it to check.

  • HEAD · from lesson 14

    Current symbolic branch reference or detached commit identity.

  • Commit · from lesson 7

    Object identifying a root tree, parent(s), metadata and message.

  • Tree · from lesson 6

    Directory snapshot mapping names, modes and object IDs.

  • Ref · from lesson 3

    Name identifying an object; branch refs usually identify commits.

  • Merge base · preview, covered in lesson 17

    Best common ancestor of commits; there may be several.

  • Reachability · preview, covered in lesson 27

    Whether an object can be reached by traversing links from roots.

Visual mental model

  1. Base A
  2. Ours: Bfirst parent
  3. Theirs: Csecond parent
  4. Merge M
Arrows show parent links (from child to parent). Branch labels identify tips.

Build the mental model

A lightweight tag is a ref to an object; an annotated tag points to a tag object with metadata and a target (usually a commit). Tags are conventionally stable release names, unlike moving branch tips. Revision syntax selects objects: HEAD~2 follows the first parent twice; HEAD^2 selects the second parent directly, if it exists. HEAD^{tree} peels to a tree.

SimulationNavigate parents and tags

A simplified model for building intuition. It does not read your sandbox; use the terminal for real behaviour.

Under the hood

For git log A..B, select commits reachable from B but not A. git log A...B selects the symmetric difference. For git diff A..B, compare the two endpoint trees; git diff A...B compares a merge base of A and B to B (normally a unique merge base). These are not interchangeable. git rev-parse resolves names; quote expressions with braces when your shell requires it.

Common mistake · important nuance

The three dots do not mean the same thing in log and diff. A tag is not necessarily immutable; moving published tags is usually a bad practice.

Move between parts freely. Completion counts only what you verify and answer.