Skip to content
Guides6 min read

Git Interactive Rebase Tutorial: Squash, Reword & Reorder Commits

Turn messy "wip", "fix lint", and "address review" commits into clean, atomic pull request commits using interactive rebase—from the terminal or visually via drag and drop.

GitKron EngineeringUpdated

Why atomic commit history speeds up code reviews

Reviewing a 25-file pull request is dramatically faster when commits are organised into logical steps—for example: schema migration first, service logic second, and integration tests third—rather than twelve chronological "fix typo" snapshots.

# Interactively clean up the last 4 local commits:
git rebase -i HEAD~4

# Common interactive rebase commands:
# pick   = keep commit as-is
# reword = keep diff, edit commit message
# squash = meld into previous commit & combine messages
# fixup  = meld into previous commit & discard this message
# drop   = remove commit completely

Visual interactive rebase vs terminal vim buffers

In terminal editors, accidentally swapping commit order or misreading top-to-bottom rebase order can trigger cascading conflicts. GitKron’s visual interactive rebase lets you drag commits to reorder them, toggle Squash/Fixup/Reword in one click, and preview potential conflicts before executing.

  • Use fixup for quick lint, formatting, or typo corrections belonging to an earlier commit.
  • Enable git config --global rebase.autosquash true when pairing git commit --fixup <sha> on the CLI.
  • Run your test suite after squashing to confirm intermediate commits still build cleanly.

Frequently asked questions

What is the difference between squash and fixup in git rebase -i?

Both combine a commit’s changes into the preceding commit, but squash opens an editor to merge both commit messages whereas fixup keeps the earlier commit message and discards the fixup commit’s message.

How do I cancel an interactive rebase if something goes wrong?

Run git rebase --abort (or click Abort Rebase in GitKron) at any point to restore your branch to its exact pre-rebase state.

All articles