Skip to main content
Module 5 · Lesson 5 of 522/34 in the course~18 min
Module lessons (5/5)

Time machine rescue with git reflog

Lesson preview5 hands-on exercises readyGit & Modern Collaboration · Module 5 — Undoing Mistakes & Recovery

Use Reflog X-Ray and HEAD@{N} offsets to recover commits orphaned by reset or amend.

What you'll learn in this lesson

  • Use Reflog X-Ray (git reflog) to locate commits orphaned by reset --hard, amend, or branch deletion.
  • Rescue apparently lost commits instantly via git reset --hard HEAD@{N} or a brand-new safety branch.
  • Recognize exact boundaries of git reflog: commits saved vs uncommitted edits never staged/committed.

Overview

Running git reset --hard HEAD~1 right after creating an important commit feels horrifying: git log shrinks and your Stripe integration commit seems to vanish!

Yet commits inside .git/objects are immutable! Moving feat/checkout backward only made that commit unreachable (orphaned) from branches. Git privately logs every local jump of HEAD inside a chronological diary called the Reflog (git reflog):

Sections covered in this lesson

  1. 1Nothing Committed Disappears Immediately
  2. 2Trace Orphan Rescue Inside the Matrix Lab
Pro Lesson · Module 5 — Undoing Mistakes & Recovery

Unlock "Time machine rescue with git reflog" and the full Git & Modern Collaboration curriculum

Use Reflog X-Ray and HEAD@{N} offsets to recover commits orphaned by reset or amend.

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.