Module · 5 lessons

Rewriting and Recovering History

Reshape your commit history cleanly and rescue work you thought was gone — rebase, interactive rebase, cherry-pick, reflog, and bisect.

At a glance

Level
Intermediate
Lessons
5 lessons
Time to complete
1 week
Cost
Free forever · no sign-up

Welcome to Rewriting and Recovering History, the seventh module of the course — where Git stops feeling like a recording device and starts feeling like an editing studio. So far you’ve added to history; now you’ll learn to reshape it: replay commits onto a new base, squash a trail of false starts into one clean commit, copy a single fix from one branch to another, and — crucially — bring back work you thought you’d destroyed. These are the tools that separate someone who uses Git from someone who is genuinely fluent in it.

You’ll start with rebase vs merge, the central choice for combining branches, and learn when each is the right call. Then you’ll polish commits with interactive rebase (squash, reword, reorder, drop), copy commits precisely with cherry-pick, and finish with the recovery toolkit every developer eventually needs: reflog (Git’s safety net), detached HEAD, and git bisect for hunting down the commit that introduced a bug. The guided project ties it together: polish a messy branch and rescue a “lost” commit.

There’s one rule that governs this whole module, and it’s worth saying up front: rewriting history is safe on commits you haven’t shared, and dangerous on commits you have. Every command here was run for real. Start with Lesson 1 on rebase vs merge.

Lessons in this module

Achievement

Complete all 5 lessons to finish the Rewriting and Recovering History module.

Start module