Rewrite Local Commits With Interactive Rebase

Reorder, squash, reword or drop commits before sharing them.

macOSautomationgitcliLow risk
Run git rebase -i HEAD~3 to edit the last three commits in your editor.

01Command

Command
$ git rebase -i HEAD~3

02What 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

RiskLow risk
RequirementsGit 2.20+ (install with Homebrew or Xcode Command Line Tools)
CompatibilitymacOS with Git installed (Homebrew or Xcode Command Line Tools)
!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 documentation
    Git · vendor-doc · 2026-09-20
    Evidence: Documents interactive rebase, including reword, squash, edit and drop.

Last verified: 2026-10-13 · Category: Developer