Skip to main content
Module 2 · Lesson 4 of 49/34 in the course~17 min
Module lessons (4/4)

Time travel, Detached HEAD rescue & release tags

Lesson preview5 hands-on exercises readyGit & Modern Collaboration · Module 2 — History Inspection, Diffs & Time Travel

Check out past commits safely, rescue accidental detached work onto a branch, and create annotated tags.

What you'll learn in this lesson

  • Distinguish Detached HEAD (pointing directly at a raw SHA) from a named branch pointer.
  • Create lightweight and annotated release tags (git tag -a v1.0.0 -m "...") safely.
  • Rescue commits accidentally created while detached by attaching a named branch (git switch -c).

Overview

Normally HEAD points symbolically to a branch ref (HEAD → main → SHA), so making a new commit advances main forward automatically.

Checking out a raw commit (git checkout HEAD~1 or git switch --detach v1.0.0) detaches HEAD so it points directly to a raw commit SHA. Reading files there is completely safe — the danger arrives if you make new commits while detached and switch away without anchoring them to a branch name!

Sections covered in this lesson

  1. 1Time Travel Without Losing Commits
  2. 2Walk Through Detached HEAD & Branch Rescue Live
Pro Lesson · Module 2 — History Inspection, Diffs & Time Travel

Unlock "Time travel, Detached HEAD rescue & release tags" and the full Git & Modern Collaboration curriculum

Check out past commits safely, rescue accidental detached work onto a branch, and create annotated tags.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Git & Modern Collaboration plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.