Rewrite Local Commits With Interactive Rebase
Reorder, squash, reword or drop commits before sharing them.
Run git rebase -i HEAD~3 to edit the last three commits in your editor.
01Command
Command
$ git rebase -i HEAD~302What it does
Interactive rebase opens a todo list where you can reorder commits, squash fixups, reword messages or drop mistakes, producing a clean reviewable history. This history-shaping workflow only exists on the command line and is a core reason developers script and operate in a terminal.
03Risk
!Warning: Rewriting commits that others have already pulled creates divergent history; only rebase commits that are still local.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- git-rebase documentationEvidence: Documents interactive rebase, including reword, squash, edit and drop.
Last verified: 2026-10-13 · Category: Developer