gitatlassian-sourcetreesourcetree

How to properly squash commits using SourceTree?


We're using Git as our source control system, and I like to commit my code on a regular basis. This does mean that when I'm ready to push to the shared repo I've created quite a few nonsense commits that I'd like to squash away before pushing.

Using SourceTree that should be a simple thing, but I keep running into issues where not all selected commits are being squashed together. Let me show some images of what I do using a sample repo with some checkins:

Initial situation

I click the first checking and choose to 'rebase children interactively'

Context menu

A pop will appear with all the checkins:

Popup

On this popup I click the 'fifth' checkin and hit the squash with previous 3 times until the screen looks like this:

Squashed in popup

All's fine you'd think, but then when hitting the 'ok' button, this is what I end up with:

End result

Why oh why does it not include the 'Second' commit in the end result? Judging by the looks of the popup you'd think this is included as well. I can do the same thing again to get the second in there, but I just can't fathom why it works this way or how to squash them all in one go.

Any help would be appreciated.


Solution

  • It was a bug in SourceTree, see this bug report. According to the bug history, it was closed as fixed in May 2021.