Interactive Rebase#
Interactive rebase rewrites commit history before merging a feature branch. It turns a messy series of “WIP”, “fix typo”, and “actually fix it” commits into a clean, reviewable sequence.
Start an interactive rebase covering the last 5 commits:
git rebase -i HEAD~5Or rebase everything since the branch diverged from main:
git rebase -i mainGit opens your editor with a list of commits. Each line starts with an action keyword: