我已经用我的git配置了 kDiff3。
我需要的是查看两个分支之间的目录差异。当我跑步时
git difftool <headbranch>
命令它一个一个地打开所有文件。但这不是我想要的。
git-difftool(1)现在满足这个用例。只需使用 --dir-diff(或 -d)开关:
-d
--dir-diff
Copy the modified files to a temporary location and perform
a directory diff on them. This mode never prompts before
launching the diff tool.
例如:
git difftool -d --tool=kdiff3 10c25f0da62929cca0b559095a313679e4c9800e..980de1bbe1f42c327ed3c9d70ac2ff0f3c2ed4e1
另请参阅https://www.kernel.org/pub/software/scm/git/docs/git-difftool.html
我还没有发现使用 kdiff3 和标准 git 工具在目录比较模式下查看两个分支之间的目录差异的可能性。
使用标准工具可以做什么(如果我错了,请纠正我:)是使用 difftool 逐个文件比较,并使用以下命令在控制台中进行概述:
git diff --name-status <other-branch>
但是我找到了Comprehensive Graphical Git Diff Viewer Script,它为我完成了所需的工作 - 比较 kdiff3 中的整个目录。
该工具只是一个 shell 脚本,它在 /tmp 文件夹中创建要比较的分支快照并在它们上运行 kdiff3 文件夹比较。
在此处签出脚本
你可以使用
git diff --name-status <other-branch>
它列出了具有差异的文件,状态为 A/M/D。
比方说,我们有两个分支master和base 为了查看这些分支之间的区别,只需执行:
git difftool -d base:src/ master:src/
然后你的预设差异工具应该开始了,在我的例子中是 kdiff3。或者您也可以使用该--tool
选项来启动另一个:例如使用vimdiff
git difftool -d --tool=vimdiff base:src/ master:src/
或以相同的方式使用kdiff3
git difftool -d --tool=kdiff3 base:src/ master:src/