The Git Rescue Kit — Undo Anything
Cherry-Pick, Interactive Rebase, and Looking Like You Know What You're Doing
Curating History on Purpose
Cherry-Pick: Grab One Commit From Anywhere
git cherry-pick <commit-hash> # apply one specific commit onto your current branch
Useful for the classic "that hotfix landed on main, now port it onto the release branch too" situation — without merging in everything else main has picked up since.
Interactive Rebase: Edit History Before Anyone Sees It
git rebase -i HEAD~5 # open the last 5 commits for editing
This opens an editable list where each commit can be picked as-is, reworded, squashed into the previous commit, or dropped entirely. It's how twelve messy "wip", "fix", "actually fix" commits become one clean commit with a real message — before opening a PR, never after someone's already reviewing it.
| Action | Effect |
|---|---|
pick |
Keep the commit as-is |
reword |
Keep the changes, edit the message |
squash |
Merge into the previous commit, combine messages |
fixup |
Merge into the previous commit, discard this message |
drop |
Remove the commit entirely |
Putting It Together
None of this is exotic. It's the baseline for working on a team without creating a mess for everyone downstream — which, unfortunately, is not the same thing as years of tenure.
Congratulations — you now know more usable git than most people pick up in a decade of pointing and clicking in a GUI and asking a teammate every time something looks scary. Use it well. Maybe forward Module 4 to someone who needs it.
What's the correct tool to combine five messy "wip" commits into one clean commit before opening a PR?