SourceTree equivalent of git diff master...feature

Erik Vandekieft
Contributor
December 21, 2011

Hi,

I love the SourceTree diff UI but I need to diff the common ancestor of two branches. In git, the command for this is:

git diff master...feature

Where 'feature' is some feature branch head. Note the triple-dot notation. This means that you want not the difference between the heads of "master" and "feature" but the difference between the common ancestor of "master" and "feature" and the head of "feature".

Is there a way to do this?

Thanks

--Erik

1 answer

1 accepted

8 votes
Answer accepted
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 22, 2011

In SourceTree you can diff any 2 points in history just by Cmd-clicking to select two commit lines in the log view - the differences between those 2 commits, wherever they are, is then displayed. So that includes diffing the common ancestor and the head of the feature branch. However, right now you have to find this common anscestor in the log yourself, there's no automated selection of it.

Erik Vandekieft
Contributor
December 22, 2011

Thanks, I didn't realize you can cmd-click to diff two commits. I noticed it also displays diff output when more than two are selected-- what exactly is it showing?

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 22, 2011

It shows the difference between the outermost selected rows. This is just for convenience in case you use Shift-click instead of Cmd-click.

Erik Vandekieft
Contributor
December 22, 2011

Steve, thanks a lot for all the help. Sorry, there's one last thing I've never understood. When you click on a single commit, obviously it's showing the diff between that commit and its parent. But when the commit is a merge commit, there are two parents. So what does it display then? (I suppose this is more of a fundamental git question than SourceTree...)

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 22, 2011

At the top of the diff pane in the log view is a pop-up list which says 'Diff Parent' by default. When you select a merge commit, selecting 'Diff Merged' there instead will display the differences to the merged commit rather than the first parent.

Luca de Alfaro
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 20, 2015

In gitk, I can ask between the difference between any two commits - that they are one the ancestor of the other, or not. In SourceTree, this is not possible then? The shift-click trick works only for commits related by an ancestry relation, right?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events