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 completelyVisual 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.
Explore related tools
More from the GitKron Blog
All articles- TutorialsGetting Started with GitKron: Visual Git Setup in 5 MinutesSet up GitKron on macOS, Windows, or Linux, connect GitHub or GitLab via OAuth, configure SSH commit signing, and navigate your first interactive commit graph.
- Engineering PracticesMastering Team Git Workflows: Trunk-Based vs Gitflow in 2026Compare trunk-based development and structured release branching for modern engineering teams—and learn how to cut PR cycle times and branch drift.
- GuidesHow to Resolve Git Merge Conflicts Safely Without Breaking BuildsLearn why 2-way conflict markers cause regressions and how a true 3-way merge view (base, yours, theirs) makes complex Git conflicts predictable.
- AI & ProductivityWriting Better Git Commit Messages with Explainable AIReplace "fix stuff" and "wip" history with structured Conventional Commits generated from staged diffs—while keeping human review and privacy intact.
- Git FundamentalsGit Rebase vs Merge: When to Use Each in Team RepositoriesLearn the exact difference between git rebase and git merge, when linear history helps code reviews, why force-pushing shared branches breaks teammates, and how to use --force-with-lease safely.
- TutorialsHow to Undo the Last Git Commit Safely (reset, revert & reflog)Committed to the wrong branch or forgot a file? Learn whether to use git reset --soft HEAD~1, git commit --amend, git revert, or git reflog without losing uncommitted work.
- GuidesHow Git Cherry-Pick Works: Backport Hotfixes Without Branch DriftApply specific bug-fix commits across release branches cleanly using git cherry-pick -x, handle cherry-pick conflicts in 3-way view, and avoid duplicate history.