IntelliJ:查看本地和 git commit/branch 之间所有更改文件的差异

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9825106/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:17:10  来源:igfitidea点击:

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

gitintellij-idea

提问by Jon Tirsen

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).

使用 IntelliJ 的差异查看器是一种非常好的代码方式,因为您可以使用 IntelliJ 代码编辑器的所有功能(重构、完成等)在本地版本中进行更改。

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).

不幸的是,当您在 IntelliJ 中进行代码时,我还没有弄清楚如何做最重要的事情,即:查看工作树中所有更改文件的差异(检出到您要从中合并的分支)和另一个分支(您计划合并到的分支,例如“master”)。

Does anyone know how to do this?

有谁知道如何做到这一点?

采纳答案by unknownerror

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

尽管 Jon Tirsen 的答案是正确的,但您需要通读整篇文章才能了解如何做到这一点。

Here's the images of the same in mac.

这是mac中相同的图像。

  1. I am currently working with hello_world and want to compare with master. enter image description here

  2. Next a window will pop up. Select Filesand press cmd + d

  1. 我目前正在使用 hello_world 并想与 master 进行比较。 在此处输入图片说明

  2. 接下来会弹出一个窗口。选择Files并按下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.
  1. 另一个显示差异的窗口。您可以执行许多不同类型的差异。使用cmd + shift + ]cmd + shift + [在文件之间切换。

enter image description here

在此处输入图片说明

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

差异提示:IntelliJ 提供了高级差异功能。您可以检查第三张图片上的内容。

回答by Jon Tirsen

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.
  1. 查看您要比较的分支之一。
  2. 在 IntelliJ 窗口右下角状态栏中的 Git 分支弹出窗口中选择要与之比较的分支。显示带有一些选项的弹出窗口。
  3. 选择“比较”选项。
  4. 这默认显示所有提交,您也可以选择“差异”选项卡来显示实际更改。

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

这在他们的一篇博客文章中有更详细的描述。

回答by WesternGun

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

这是现在实施的。您右键单击该项目并选择“Git - 与分支比较...”并选择master分支。完毕。区分所有文件。

回答by Yosi

This has been changed in the 2020 version update:

这在 2020 版本更新中已更改:

You now need to do the following:

您现在需要执行以下操作:

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

  2. Open the Branchesmenu.

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

  4. Select "Show Diff with Working Tree".

  1. 签出您要比较的分支之一。

  2. 打开分支菜单。

  3. 选择要与之比较的其他分支。

  4. 选择“使用工作树显示差异”

enter image description here

在此处输入图片说明

回答by sonal balekai

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.

右键单击该类并选择 Git 选项,您将在其中看到与分支选项进行比较,您可以在其中选择特定分支。

回答by urgentx

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.

如果您只想以并排方式将当前打开的文件与另一个分支进行比较,只需转到 VCS -> Git -> 与分支比较。