Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ and Git: How to see diffs between a commit and two older commit?

You probably know this window where you can see the diffs between a commit to ONE commit older.

enter image description here

Do you know how can I see exactly the same comparison, but between a commit and a previous commit which is not necessarily ONE before the current one.

I know that I can do it per one file, but I want to do it for the whole project.

like image 821
CrazySynthax Avatar asked Jun 12 '17 10:06

CrazySynthax


3 Answers

You can select any number of commits in the git log window (using shift/ctrl and click or cursor keys) and the right-hand pane will show the cumulated differences.

like image 159
Stephen Friedrich Avatar answered Nov 06 '22 01:11

Stephen Friedrich


In IntelliJ, there is no command or action to compare exact revisions, unfortunately. Here are couple related requests: https://youtrack.jetbrains.com/issue/IDEA-125616 and https://youtrack.jetbrains.com/issue/IDEA-100431

However, there is a way to see what has changed between two commits. To do so you need to go to the Version control - Log tab and select the entire range between wanted commits (e.g select the later commit, then scroll down to the older commit and click on it with Shift). In the right pane showing changed files you will see all the changes.

like image 27
Dmitriy Smirnov Avatar answered Nov 06 '22 00:11

Dmitriy Smirnov


Another way to do it:

  1. Open the 1: Project panel
  2. Right-click your project's root folder
  3. Select GitShow History from the menu

This opens up a completely different view of the git log, where you can do exactly what you'd expect to be able to from the main (9: Version Control) git log... namely:

  1. Select (only!) two commits
  2. Click Compare

From the pop-up dialog that appears, you can select any file and press Ctrl-/Cmd-D (or right-click and select the only menu item) to see the changes.

Unfortunately, there doesn't seem to be any way to "pin" that view to your workspace, though it hovers on top as long as you need it.

Hopefully one day JetBrains will create a "best of both worlds" merged version of these UIs, so we can just compare stuff from the main Version Control log. To add to the list of JetBrains tickets for this issue listed in another answer... the oldest one appears to be https://youtrack.jetbrains.com/issue/IDEA-86480

like image 31
Lambart Avatar answered Nov 05 '22 23:11

Lambart