Lesson 15 / 28

Interactive Rebase

Clean up recent commits with interactive rebase: reword, squash, reorder or drop before sharing.

Clean up before pushing

Opens an editor listing your last 3 commits — mark each pick, squash, reword, or drop.

git rebase -i HEAD~3

Output:

pick a1b2c3d Add login form
squash 9f8e7d6 Fix typo
squash 4d5e6f7 Fix another typo

Squashing fixups

Interactive rebase is great for turning "fix typo" commits into one clean commit — but only on branches you haven't shared yet.