Squashing Commits in Towergit: How, When, and What to Watch Out For
Learn how to use Towergit’s squash‑commit feature, the mechanics behind the operation, and the common pitfalls to avoid. Verify the new commit graph and coordinate force pushes when needed.
12 Oct 2026, 12:49 UTC

What You Can Do With Towergit’s Squash Commit
When you’ve made a handful of small, incremental commits that belong together, Towergit lets you collapse them into a single, cleaner commit. The Squash commit action is available from the right‑click context menu on a commit and from the command palette (Ctrl+Shift+S). After the operation, the new commit carries the message of the earliest selected commit and the author of the top‑most commit in the selection.
Step‑by‑Step Example
- Open the History view and select three consecutive commits on your current branch:
c3a1b2c,d4e5f6g, andh7i8j9k(top to bottom). - Right‑click one of the selected commits and choose Squash commit, or press Ctrl+Shift+S and type "Squash commit" in the command palette.
- Towergit pops a confirmation dialog showing the number of commits to squash. Click Confirm.
- The three commits are replaced by a single commit
l0m1n2o. The commit message is that ofc3a1b2cand the author is the author ofh7i8j9k. - Run
git log --onelinein the integrated terminal to verify the new history: the three old hashes no longer appear.
How the Operation Works Under the Hood
- Towergit internally runs
git rebase -iwith the--autosquashflag, selecting the range up to the first commit in your selection. - The rebase rewrites the commit graph locally; no remote references are altered until you push.
- After the squash, the new commit’s timestamp is set to the earliest of the selected commits, and its author field is taken from the top‑most commit.
Limitations and Common Mistakes
- Only local history is affected. Remote‑tracking branches remain unchanged until you push. If the commits you squash have already been pushed, you must perform a force push (
git push --force-with-lease) to update the remote. - Do not squash commits that are already shared. A non‑force push after squashing will be rejected, and you risk losing the original commits if you ignore the warning.
- Selection order matters. Towergit expects the commits to be selected in chronological order (oldest first). Selecting in reverse can produce an unexpected commit graph.
- Branch context. The squash action is only available when you are on a branch that contains the selected commits. It cannot squash commits from other branches or tags.
Practical Verification Checklist
- After squashing, run
git log --graph --onelineto confirm the commit count decreased by the expected amount. - If the branch is tracking a remote, attempt a push. Towergit will prompt for a force push if the remote history diverges.
- Coordinate with teammates before force‑pushing. Use
git fetchandgit log origin/branchto compare histories.
When to Use Squash Commit
- When you want a tidy feature branch before merging into
main. - When you’ve made multiple small bug‑fix commits that logically belong together.
- When preparing a pull request that should contain a single descriptive commit.
Takeaway
Towergit’s squash commit is a quick, UI‑driven way to clean up local history, but it rewrites commit IDs. Use it only on unshared commits or coordinate a force push when necessary, and always verify the new commit graph before pushing.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.