IntelliJ: Viewing diff of all changed files between local and a git commit/branch

GitIntellij Idea

Git Problem Overview


Using IntelliJ's diff viewer is a very nice way to review code because you can make changes in your local version with all the capabilities of the IntelliJ code editor (refactoring, completion, etc).

Unfortunately I have not worked out how to do the most important thing when you're doing code reviews in IntelliJ, namely: Looking at the diff of all the changed files in the working tree (checked out to the branch you want to merge from) and another branch (the branch you plan to merge into, e.g. "master).

Does anyone know how to do this?

Git Solutions


Solution 1 - Git

This has now been implemented. In order to compare two branches you do:

  1. Check out one of the branches you want to compare with.
  2. Select the branch you want to compare with in the Git branch popup in the status bar in the bottom right of the IntelliJ window. A popup with some options is shown.
  3. Select the "Compare" option.
  4. This by default shows all the commits you can also select the "Diff" tab to show the actual changes.

This is all described in much greater detail in one of their blog posts.

Solution 2 - Git

Though Jon Tirsen's answer is correct, you need to go through entire text in order to understand how to do that.

Here's the images of the same in mac.

  1. I am currently working with hello_world and want to compare with master.

UPDATE: In the new UI, click on Show Diff with Working Tree

enter image description here

  1. Next a window will pop up. Select Files and press cmd + d

enter image description here

  1. Another window which shows diff. You can perform many different types of diff. Use cmd + shift + ] and cmd + shift + [ to shift between files.

enter image description here

Diff Tip: IntelliJ provides advanced diff features. You can check those on the 3rd image.

Solution 3 - Git

This has been changed in the 2020 version update:

You now need to do the following:

  1. Checkout one of the branches you want to compare.

  2. Open the Branches menu.

  3. Select the other branch you want to compare with.

  4. Select "Show Diff with Working Tree".

enter image description here

Solution 4 - Git

This is implemented now. You right-click on the project and select "Git - compare with branch..." and choose master branch. Done. Diff all files.

Solution 5 - Git

If you just want to compare your currently open file with another branch in a side-by-side fashion, just go to VCS -> Git -> Compare with Branch.

Solution 6 - Git

Right Click on the class and select the Git option where you will see compare with branch option where you can select the particular branch.

Solution 7 - Git

If you want to compare the whole project.

  • First. Select/click the project you are working on.
  • Go to Git(tab) > Selected Directory > Compare with branch
  • Then select the branch you want to compare. (ie origin/main)

Then you will get a tree of the different files between branches. You can select each one and compare, edit, delete, add anything you may need.

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJon TirsenView Question on Stackoverflow
Solution 1 - GitJon TirsenView Answer on Stackoverflow
Solution 2 - GitunknownerrorView Answer on Stackoverflow
Solution 3 - GitBlueYoshiView Answer on Stackoverflow
Solution 4 - GitWesternGunView Answer on Stackoverflow
Solution 5 - GiturgentxView Answer on Stackoverflow
Solution 6 - Gitsonal balekaiView Answer on Stackoverflow
Solution 7 - GitMauricio ToledoView Answer on Stackoverflow