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:
I click the first checking and choose to 'rebase children interactively'
A pop will appear with all the checkins:
On this popup I click the 'fifth' checkin and hit the squash with previous 3 times until the screen looks like this:
All's fine you'd think, but then when hitting the 'ok' button, this is what I end up with:
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.
As a general rule, when merging a pull request from a feature branch with a messy commit history, you should squash your commits. There are exceptions, but in most cases, squashing results in a cleaner Git history that's easier for the team to read.
When you select the Squash and merge option on a pull request on GitHub.com, the pull request's commits are squashed into a single commit. Instead of seeing all of a contributor's individual commits from a topic branch, the commits are combined into one commit and merged into the default branch.
It was a bug in SourceTree, see this bug report. According to the bug history, it was closed as fixed in May 2021.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With