Gitflow
🧹Pre-PR History CleanupMedium+500 XP
Workshop
Scenario reference

Pre-PR History Cleanup: the situation, step by step

The situation

11 commits including 'WIP', 'fix typo', 'actually fix it'. Tech lead won't approve.

Squash 11 messy commits into 3 clean ones.

Medium · 4 steps · +500 XP

What you will practice

This scenario walks through 4 steps, in order:

  1. 01View messy history
  2. 02Interactive rebase
  3. 03Force push clean history
  4. 04Verify
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. View messy history
    git log --oneline
  2. 2. Interactive rebase
    git rebase -i HEAD~11
  3. 3. Force push clean history
    git push --force-with-lease
  4. 4. Verify
    git log --oneline

Key takeaway

11 → 3 clean commits. Many teams enforce squash-merge automatically.