在 GUI 中探索 git-diff 输出?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4160224/
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
Explore git-diff output in a GUI?
提问by Frank
Is there program that allows output of a git-diff command to be explored in a GUI?
是否有程序允许在 GUI 中探索 git-diff 命令的输出?
What i am looking for is something similar to the how SmartGit displays its view of the differences between the working copy and the HEAD. Where each of the files that are different to the HEAD are displayed and the diff for the focused file is displayed.
我正在寻找类似于 SmartGit 如何显示工作副本和 HEAD 之间差异的视图。显示与 HEAD 不同的每个文件的位置,并显示聚焦文件的差异。
I am not sure if it is possible to make SmartGit display the output of a "git diff" command.
我不确定是否可以让 SmartGit 显示“git diff”命令的输出。
回答by Tim Henigan
Starting with git v1.7.11, you can use git difftool --dir-diff
to perform a directory diff.
从 git v1.7.11 开始,您可以使用git difftool --dir-diff
来执行目录差异。
The answer that follows applies to git installations older than v1.7.11.
下面的答案适用于 v1.7.11 之前的 git 安装。
As mentioned by others, git difftool
may be used to open your diff in a GUI. However if you have multiple files with changes, it will open a separate instance of the GUI for each file.
正如其他人所提到的,git difftool
可用于在 GUI 中打开您的差异。但是,如果您有多个更改的文件,它将为每个文件打开一个单独的 GUI 实例。
I wrote a script to work around this "feature" and allow all the files to be opened in a single GUI instance. You can find the git diffall
script on GitHub.
我编写了一个脚本来解决此“功能”,并允许在单个 GUI 实例中打开所有文件。您可以git diffall
在 GitHub 上找到该脚本。
Also, you may be interested in this related SO question:
此外,您可能对这个相关的 SO 问题感兴趣:
git difftool, open all diff files immediately, not in serial
回答by russellg
Beyond Comparedoes this nicely - no configuration changes needed to the basic 'git diff' command which creates the .diff file. Beyond Compare shows all the files, that are referenced in the .diff file in a file tree view and the diff for each file as you select it.
Beyond Compare可以很好地做到这一点 - 创建 .diff 文件的基本“git diff”命令无需更改配置。Beyond Compare 在文件树视图中显示 .diff 文件中引用的所有文件,以及您选择的每个文件的差异。
In Beyond Compare, use the 'Tools -> View Patch' menu option
在 Beyond Compare 中,使用“工具 -> 查看补丁”菜单选项
回答by Greg Hewgill
回答by KiRPiCH
git difftool will run all popular ones like meld, tkdiff, etc. Also for merges you can run git mergetool.
git difftool 将运行所有流行的,如 meld、tkdiff 等。此外,对于合并,您可以运行 git mergetool。
回答by Benjol
I'm not sure I've understood your question correctly, but apparently in the next version of SmartGit (2.0, currently available in alpha), you can use the log window to do diffs between arbitrary commits - I haven't tried yet though.
我不确定我是否正确理解了您的问题,但显然在下一版本的 SmartGit(2.0,目前在 alpha 中可用)中,您可以使用日志窗口在任意提交之间进行差异 - 我还没有尝试过.
回答by Peiti Li
JetBrains products like IntelliJ, GoLand, PyCharm etc all have the diff tool built-in. If you want to have a diff between current commit vs previous commit you just right click on the left of code line and turn on Annotation, then click any annotation you will view the all the files diff.
IntelliJ、GoLand、PyCharm 等 JetBrains 产品都内置了 diff 工具。如果您想在当前提交与先前提交之间存在差异,只需右键单击代码行的左侧并打开注释,然后单击任何注释,您将查看所有文件差异。
Furthermore, if you want to view the diff of current branch vs another branch like origin/master you can do that too. You just right click on the root directory and hover over to Git menu and you click Compare with Branch and select master you view all the diffs together just like viewing a Pull Request on Github.
此外,如果您想查看当前分支与另一个分支(如 origin/master)的差异,您也可以这样做。您只需右键单击根目录并将鼠标悬停在 Git 菜单上,然后单击与分支比较并选择 master,您就可以一起查看所有差异,就像在 Github 上查看拉取请求一样。
回答by VonC
Note that you now can (git 1.7.11, June 2012) diff directories (ie display all the files to be compared, before opening the difftool, instead of running an instance of the external tool once per a file pair.)
请注意,您现在可以 ( git 1.7.11, June 2012) diff 目录(即在打开 difftool 之前显示所有要比较的文件,而不是每个文件对运行一次外部工具的实例。)
回答by drkvogel
I know you're looking for a GUI rather than a TUI, but vi/vim/vimdiff will display a diff file with syntax highlighting: view changes.diff
, where changes.diff
was created by doing git --no-pager diff > changes.diff
. I've been looking all over the place for a GUI that will read one of these files, to no avail - meld
has a --comparison-file=COMPARISON_FILE
option, but whatever that comparison file format is, it doesn't work with regular (unified) diff output.
我知道您正在寻找 GUI 而不是 TUI,但是 vi/vim/vimdiff 将显示一个带有语法突出显示的差异文件:view changes.diff
,其中changes.diff
是通过执行git --no-pager diff > changes.diff
. 我一直在到处寻找可以读取这些文件之一的 GUI ,但无济于事 -meld
有一个--comparison-file=COMPARISON_FILE
选项,但无论比较文件格式是什么,它都不适用于常规(统一)差异输出。