git rebase -i HEAD~n opens your editor on a "todo list" of the last n commits, oldest first:
pick a1b2c3d feat: add login
pick d4e5f6a fix: typo
pick 7g8h9i0 feat: add logout
Change the verb on any line to tell Git what to do with that commit:
- pick — keep as-is (default).
- reword — keep the changes, but stop so you can rewrite the message.
- squash — meld into the previous commit; you'll edit the combined message.
- fixup — like squash but discard this commit's message.
- drop — remove the commit entirely.
- edit — pause at this commit so you can amend, split, or add files.
You can also reorder by rearranging the lines. Save and close — Git replays the commits according to your instructions.
Pair with git commit --fixup=<hash> plus git rebase -i --autosquash to automatically slot fixup commits next to their targets. Only rebase commits that haven't been pushed.
This terminal has no editor, so -i cannot open the todo list here. The verbs still map to commands that do run: reword on the newest commit is git commit --amend; squash of the last n commits is git reset --soft HEAD~n followed by one git commit; drop of the newest is git reset --hard HEAD~1.