50

Is there any way to compare 2 branches (branch1 and branch2) with gitkraken?

I want a list of files that have changes

Michalis
  • 6,686
  • 13
  • 52
  • 78

6 Answers6

27

If you want to find out difference between branch A and B First checkout on branch A then click on branch B and select commits it then you can find changes on right panel.

and can select multiple commit rows in the graph using Shift Click to show its merged diff

amin saffar
  • 1,953
  • 3
  • 22
  • 34
  • 3
    I use Shift key and click on commit and select them , try it – amin saffar Nov 09 '18 at 23:34
  • 2
    I think using the Ctrl key is a better solution. Using the shift key does not the intended result. It shows the "merged diffs" which is not equivalent to comparing the last commits of both branches. – lucaslugao Apr 19 '19 at 14:17
  • @LucasLugãoGuimarães I test it now and ctrl have same result as shift key! – amin saffar Apr 19 '19 at 14:46
  • @aminsaffar If you have file deletions or other intermediate manipulation to the tree between the commits you could end up with two different results for the shift and ctrl key. – lucaslugao May 20 '19 at 02:17
  • 1
    For mac, use 'cmd' key instead of 'ctrl' key to see the difference between two commits. push 'cmd' key for the second commit only. – Brian Hong Mar 23 '21 at 16:47
  • 1
    This back and forth is a bit confusing so I want to clarify things for everybody. When you select 2 commits (using either cmd-click or shift-click, doesn't matter), you will get the diff between those 2 commits. Which is what you want when you compare 2 branches. Just select the latest commit for each branch and you're good. But if you select more than 2 commits (again, using either cmd-click or shift-click), you will get something totally different: a "merged diff". A merged diff is literally just a direct merging of each commit's diff. Which is not what you want when comparing 2 branches. – jaquinocode Jun 10 '22 at 17:18
25

GitKraken allows you to compare two branches, and the commits from each branch, by CMD/CTRL-clicking the two commits from different branches to see their differences. If you want to compare the latest commits to each branch, you'd CTRL-Click the head commit from each branch.

Dave
  • 1,111
  • 8
  • 16
19

GitKraken, as far as I know after some looking into that matter, doesn't let you compare branches regarding their commits. One way to do what you want though, is to use Soloing; you right-click the first branch you want to compare and choose 'Solo'. Orange circles will appear to the left of the branches names instead of the eye. Then click the faded orange icon next to the second branch you want to solo. Only those branches will be shown in the commit view.

Then you just select one commit, and click the second while holding Shift. The list of changed files will appear on the right. Clicking on a file will also show you the diff of contents.

It's worth mentioning though that you can't set the direction of the diff (source and target branch) ; but this has helped me to find out what's changed between two branches.

Mickael V.
  • 1,109
  • 11
  • 21
  • 4
    I'm not sure I understand why you'd need to enter Solo mode. I can click to select _any_ a commit, then shift click any another, and the diff is shown in the GitKraken sidebar, no soloing required. – ruffin Mar 25 '20 at 13:31
  • 1
    Indeed you can, but if you have a lot of branches it can be a hassle to locate the two commits. The question being specifically how to compare branches, soloing them brings a first filter that can help to compare branches. – Mickael V. Mar 26 '20 at 11:02
3

I don't know if this feature is recent, but it is very simple in GitKraken now to display the diff of 2 branches.

You just have to click on the commit of the first branch, hold Shift key, and click to the second commit, which can be anywhere so for example a commit of the second branch.

You can solo the 2 branches for simplifying the graph before to do this action.

pom421
  • 1,731
  • 19
  • 38
2

There are two different ways I examine differences between two branches:

  • Use "git difftool branch1..branch2" where I have my difftool specified to be a graphical tool (I typically use xxdiff).

  • The other method (probably easier) is to use the compare branch functionality in the most excellent Visual Studio Code. See here for additional detail: How to compare different branches in Visual Studio Code

Remy Orange
  • 151
  • 1
  • 2
-2

I want a list of files that have changed

git whatchanged

  • You can always use the command line and use the git whatchanged command. Full documentation can be found at https://git-scm.com/docs/git-whatchanged.
  • This command supports many of the git log flags so you can use them as well

enter image description here


based upon the comment:

let's say that 2 coworkers work at the same bug... and you want to compare the 2 branches.... to find the best solution (real example)

There are few ways to find differences between 2 branches:

**In case you get empty result swap the branches

  • git diff <branch1>...<branch2>
  • git diff <branch1> ^<branch2>
  • git log <branch1>...<branch2>
  • git whatchanged
Eric Pohl
  • 2,324
  • 1
  • 21
  • 31
CodeWizard
  • 128,036
  • 21
  • 144
  • 167