237

Does Sourcetree offer a way to visualize differences between git branches?

I'm looking for:

  • names of files that have changed
  • diffs between these files
isherwood
  • 58,414
  • 16
  • 114
  • 157
Snowcrash
  • 80,579
  • 89
  • 266
  • 376

5 Answers5

299

Use (OSX) or CTRL (Windows and Linux) and choose any two commits you like in log view. It does not matter what branch the commits belong to.

As a result you will see something like...

Displaying all changes between f03a18bf0370c62bb5fb5c6350589ad8def13aea and 4a4b176b852e7c8e83fffe94ea263042c59f0548

...down below.

Jeroen
  • 60,696
  • 40
  • 206
  • 339
Anton Glukhov
  • 3,507
  • 1
  • 15
  • 16
  • That was the intuitive thing to do and I tried it. For some reason it isn't working on version: 2.1 on Mavericks 10.9.5. Odd, the command below seems to be working. – eco Jul 29 '16 at 20:32
  • For anyone dense like me, CMD = Command ⌘. The answer is basically suggesting if you multi-select any two commits, Sourcetree automatically shows you the difference. I prefer Gan's answer, but if this is more general-purpose. – KC Baltz Jun 16 '17 at 17:33
  • 3
    Was about tho ask the same thing for **GitKraken, where it turns out to work similarly**. – Jeroen Nov 06 '17 at 12:51
  • Awesome. Works even if one branch is local and the other is the remote I'm about to force-push to – Reversed Engineer Jul 15 '19 at 12:35
  • This doesn't show a branch diff if you've recently merged one into the other, only recent commits between the selections and not the whole branch – G Huxley Jul 08 '22 at 00:04
  • With Mercurial, what you call Log View is called History View instead. – Philippe Cloutier Mar 31 '23 at 15:21
244

Another way to do this is to right-click on a branch and select the "Diff against current" context menu command (current refers to the branch you are currently working on). This will give you the diff between the head commits of the two branches.

Source: https://answers.atlassian.com/questions/167126/sourcetree-diff-against-current-behavior#

Screenshot (based on Sourcetree v1.9.5):

enter image description here

After choosing "Diff against Current" from the context menu, you should see a message to the effect of:

Displaying all changes between {commit_hash} and working copy

After choosing to "Diff against Current" you should see a list of files that have changed, beneath the message "Displaying all changes between {commit_hash} and working copy"

Nate Anderson
  • 18,334
  • 18
  • 100
  • 135
Gan
  • 4,827
  • 3
  • 34
  • 50
21

You can also do this by ctrl + clicking the two branches commits you want to diff.

Mus
  • 7,290
  • 24
  • 86
  • 130
Taran
  • 12,822
  • 3
  • 43
  • 47
4

On macOS hold the key, click over first branch, later secondary click over the second branch and select Diff Against Current option on Popup Menu.

enter image description here

At the right Hand, you can see the difference.

enter image description here

joseluisbz
  • 1,491
  • 1
  • 36
  • 58
1

You can also use an External Diff tool. For example I am using Beyond Compare. After you set it as an external diff tool in sourcetree, you select both files you want to compare using CTRL and after that you press CTRL+D. As a result, Beyond Compare will be launched with both files ready to be compared.

lsc05
  • 11
  • 2