最近我在使用 GitExtension 2.46,但与之相同的 Git 版本是 1.9.4.msysgit.2。为了只使用 Git 命令,我卸载了 GitExtension 并安装了可用的最新版本 Git和 KDiff3 .
当我进行 merge 并发生冲突时,我运行以下命令:
git mergetool
然后我收到消息:
The merge tool kdiff3 is not available as 'kdiff3'.
我猜它一定是通过 KDiff3 路径。
环境
- 操作系统:Windows 10
- Git 2.6.1.windows.1
- KDiff3 0.9.98(64 位)
问题:
我必须在 .gitconfig 文件中为命令
git mergetool
配置什么以打开版本为 LOCAL、REMOTE 的 KDiff3 GUI 、BASE 和MERGED 冲突文件?如何将其配置为将其用作比较工具?
最佳答案
这些网站非常有帮助,几乎,mergetool和 difftool .我使用了全局配置,但可以毫无问题地被存储库使用。您只需要执行以下命令:
git config --global merge.tool kdiff3
git config --global mergetool.kdiff3.path "C:/Program Files/KDiff3/bin/kdiff3.exe"
git config --global mergetool.kdiff3.trustExitCode false
git config --global diff.guitool kdiff3
git config --global difftool.kdiff3.path "C:/Program Files/KDiff3/bin/kdiff3.exe"
git config --global difftool.kdiff3.trustExitCode false
请注意,最新版本的 kdiff3 将可执行文件从应用程序文件夹 C:/Program Files/KDiff3 的根目录移动到应用程序文件夹内的 bin/文件夹中。如果您使用的是旧版本,请从上述路径中删除“bin/”。
trustExitCode
选项的使用取决于 diff 工具返回时您想做什么。来自 documentation :
git-difftool invokes a diff tool individually on each file. Errors reported by the diff tool are ignored by default. Use --trust-exit-code to make git-difftool exit when an invoked diff tool returns a non-zero exit code.
关于git - 如何将 KDiff3 配置为 git 的 merge 工具和差异工具?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33308482/