What can you do with an interactive rebase?
Quick Answer
git rebase -i <base> opens a list of commits you can edit: squash/fixup to combine commits, reword to fix a message, edit to amend a commit's content, drop to remove one, and reorder lines to reorder commits. Used to tidy a messy feature branch into clean, logical commits before opening a PR.
Interactive rebase lets me rewrite my recent commits. I get a list and for each one I can squash or fixup to merge it into the previous, reword the message, edit the actual content, drop it, or reorder them. I use it to turn a branch full of “wip” and “fix typo” commits into a handful of clean, meaningful commits before I open a pull request. It rewrites history so I only do it on my own unpushed branch, or I force-push with --force-with-lease if I've shared it. And if it goes sideways, rebase --abort and the reflog have my back.
squashkeeps both messages for you to combine;fixupdiscards the second message.git commit --fixup=<sha>+git rebase -i --autosquashautomates fold-in-fixes.- Only do this on unpushed / personal branches (or force-push with
--force-with-leaseand coordinate). - If a rebase goes wrong,
git rebase --abort, andgit reflogcan recover lost commits.