Using TortoiseGit’s Interactive Rebase to Clean Up Commit History
Learn how to use TortoiseGit’s Interactive Rebase from the Windows Explorer context menu to squash or edit commits, with a step‑by‑step example and safety tips.
07 Jul 2026, 23:51 UTC

The Problem: A Messy Commit History
When working on a feature branch you often end up with several small commits that fix typos, adjust whitespace, or repeat the same change. Before merging, it is useful to combine those commits into a cleaner, more meaningful history. Doing this manually with the command line can feel intimidating if you prefer a graphical workflow.
How TortoiseGit’s Interactive Rebase Works
TortoiseGit adds an Interactive Rebase… entry to the context menu of any commit shown in the Show Log view. Selecting this command launches Git’s rebase --interactive operation behind the scenes, but presents a simple dialog where you can change each line from pick to edit, squash, fixup, or drop. After you edit the list and close the editor, TortoiseGit runs the rebase and updates the branch.
Worked Example: Squashing the Last Two Commits
- In Windows Explorer, navigate to the root of your local repository.
- Right‑click → TortoiseGit → Show Log.
- In the log view, locate the commit that is the oldest of the two you want to combine (e.g.,
a1b2c3d). Right‑click that commit and choose Interactive Rebase…. - A dialog opens showing a list of commits from the selected one up to the current HEAD, each line beginning with the word
pick. Change the wordpicktosquash(orfixupif you do not want to keep the commit message) for the second line. - Save and close the editor (Notepad is used by default). TortoiseGit will then run the rebase.
- When the rebase finishes, the dialog shows a success message and the log view updates.
You can verify the result by opening Show Log again and confirming that the two commits have been replaced by a single commit with a combined message. Additionally, run git reflog from a command prompt to ensure the original commits are still reachable (they appear as HEAD@{1}, HEAD@{2}, etc.) in case you need to reset.
Limitations and Safety Checks
- The interactive rebase dialog relies on the default text editor (Notepad). If the editor is misconfigured or you save an invalid instruction list (e.g., duplicate
picklines), Git will abort the rebase and you must recover via the reflog. - Only one Git process can hold the repository lock at a time. If another TortoiseGit operation or a command‑line Git command is running, the rebase may fail with a "cannot lock ref" error.
- Rebasing rewrites history; avoid using it on commits that have already been pushed to a shared branch unless you coordinate with your team.
Actionable Closing
Next time you notice a series of trivial commits, try the TortoiseGit interactive rebase from the log view. It gives you a safe, visual way to squash, edit, or drop commits without leaving the Explorer window. Always verify the new history with Show Log and keep the reflog handy as a safety net.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.