It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

In SourceTree, how do I squash commits?

Andrew Drexler Sep 18, 2013

Your marketing blurb refers to being able to squash commits by drag and drop. I've dragged. I've dropped. No joy.

What's the trick?


8 answers

1 accepted

15 votes
Answer accepted
Jeff Thomas Atlassian Team Sep 24, 2013

Right-click on the parent commit and select 'Rebase children of <sha> interactively'. After that, you'll be able to drag and drop to squash commits.

As Jeff says, this is how you interactively rebase in SourceTree. From here though, you'll need to drag and drop the commits (represented as rows) onto one another in order to squash them.

Ludwik Szymon Janiuk Aug 23, 2014

The problem that I and seemingly others here are facing, is this: imaginge three commits, A->B->C (chronological order). Now, say I'd like to squash C into B. Judging from the answer here I should right click on B, select "rebase children interactively", and then be able to do it. But here's the problem: When I do that, only the children of B (aka, C) are shown in the dialog and available interactive rebasing. To do what I originally wanted to do, squash C into B that is, I actually have to right click A, choose, "rebase children interactively", and then B and C show up in the window, I can squash C into B, press OK and it's done.

My question is, is this a bug or is this how it's supposed to be? And if you really want it that way, what's the reasoning behind that decision?

Or, am I just missing something? ;)

Like # people like this
Tim Legrand Aug 31, 2015


Adam Gall Sep 13, 2015

@Ludwik Szymon Janiuk That's just how git works. Imagine your scenario: ``` * f5ac8a9 - (HEAD -> master) C * 8667061 - B * 2d19dc0 - A ``` To squash C into B, you would type in `git rebase -i HEAD~2`, which is equivalent to `git reabse -i 2d19dc0`, which would output: ``` pick 8667061 B pick f5ac8a9 C # Commands: # p, pick = use commit etc. ``` So to answer your question, SourceTree is most likely behaving this way on purpose, because it's mimicking how git works.

8 votes
ash_cooleman Dec 03, 2014

SourceTree 2.0.3 OSX:

  1. Select oldest commit (of the multiple commits) you want to modify aka rebase
  2. Repository -> Interactive rebase
  3. Right-click a commit and select the option "Squash with previous commit..."

edit: Atlassian have a great post on this

Marjan Venema Jul 18, 2016

Thanks for the linked post. It was extremely useful!

Like Rollin McCarty likes this
Dan Ash Dec 03, 2017

Gift keeps on giving.  Thank you.

1 vote
Wendell Thompson Oct 22, 2014

For the Windows version a good workaround is to use the "Terminal" button and execute git commands manually.

git checkout [destination branch]
git merge --squash [source branch]
0 votes
Jeff Thomas Atlassian Team Sep 24, 2013

This feature is available in the Mac OS X version of SourceTree, but I don't believe it's made it to the Windows version.

Are you using Mac or Windows?

0 votes
Jeff Thomas Atlassian Team Sep 24, 2013

Are you using Windows or Mac OS X?

I don't believe the squash commits functionality has been added in the Windows version yet.

0 votes
Andrew Drexler Sep 24, 2013

Thank you for your response!

I am using the Mac version. The site info indicates squashing can be done with drag and drop. I've tried every combination of drag/srop I can think of without success. How do you do it?

Thanks again

0 votes
Marcel Bradea Jan 29, 2014

When clicking the option on the same commit where the 'master' branch is nothing happens at all (dialog does not show up). It only works when performed either on the commit prior or the one after, which makes no sense at all. Usually you want to squish the commits you've been working on in your branch, which directly stem/root in the latest commit on 'master. Is this a bug or a design decison I am misunderstanding?

Jeff Thomas Atlassian Team Jan 29, 2014

You'll want to click on the oldest parent commit that you'd like to rebase to. This will allow you to squash any children commits from that point. The graph in SourceTree is upside down, where the parent commits are lower and children commits higher. Does that help explain it? If it doesn't, could you provide a screenshot of what you're trying to do and I might be able to help further.

Darko Damjanovic Jul 25, 2018

Yes, this seems to be a (conceptual?) bug. To test: please branch from master and branch named "dev". Then create multiple commits on "dev". Then try to squash _all_ commits from dev into one. It does not work, because you would need to do the squashing from the commit _before_ the first commit on dev. But there is no commit _before_ the first one. So it's not possible to squash all commits of one branch into one commit with Source Tree as far as I can see. (Edit: I found an ugly workaround...)

0 votes
Rajesh Bachani Nov 22, 2016

Still not available for Windows?

Gabriel GM Nov 25, 2016

I'm using Windows Version and it is available.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Sourcetree

[dev team] Sourcetree for Windows 2019 Preview - Dark Theme

Hi folks, While the full post is over on our blog I'd like to share the dark theme we've got planned for 2019 here directly as well to keep the discussion going.  The ...

1,952 views 14 18
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you