Gitflow
↩️Undo Last 3 Commits — Keep Changes StagedEasy+350 XP
Workshop
Scenario reference

Undo Last 3 Commits — Keep Changes Staged: the situation, step by step

The situation

You made 3 quick commits but now want to combine them into one polished commit with a better message.

Soft reset rewinds HEAD but leaves the working tree and index intact.

Easy · 3 steps · +350 XP

What you will practice

This scenario walks through 3 steps, in order:

  1. 01Soft reset to combine the last 3 commits
  2. 02Verify everything is staged
  3. 03Create one polished commit
Reveal the step-by-step commands

Try the terminal first — you learn more by doing. When you want to check yourself, here is the command for each step.

  1. 1. Soft reset to combine the last 3 commits
    git reset --soft HEAD~3
  2. 2. Verify everything is staged
    git status
  3. 3. Create one polished commit
    git commit -m "feat: complete feature x"

Key takeaway

--soft keeps changes staged. --mixed unstages. --hard nukes them.