在Windows上配置Git的diff-tool [英] Configuring a diff-tool for Git on Windows
问题描述
由于powershell中的 git diff
大多会导致无法读取的空白或奇怪的字符数量,因此我安装了Perforce P4Merge,以处理合并和diff。
然而,我不能让 git diff
打开p4merge应用程序来查看diff。到目前为止,我的 .gitconfig 看起来像这样:
[diff]
工具= p4diff
[ difftoolp4diff]
external ='C:/PROGRA~1/Perforce/p4merge.exe$ LOCAL$ REMOTE'
prompt = false
[merge ]
keepBackup = false
工具= p4merge
[mergetoolp4merge]
cmd =$ BASE$ LOCAL$ REMOTE$ MERGED
path ='C:/PROGRA~1/Perforce/p4merge.exe'
prompt = false
keepBackup = false
keepTemporaries = false
trustExitCode = false
路径是正确的。但是,当使用 git diff
时,git仍会尝试在Powershell中显示diff。
那么使这项工作有什么妙处?
你的命令提示符,试试: git config --global diff.tool p4diff
配置文件的设置如您所描述的:
$ pre $ $ $
$工具= p4merge
[difftool p4diff]
external ='C:/ Program Files / Perforce / p4merge.exe$ LOCAL$ REMOTE'
运行 git difftool
按预期打开了p4merge。
Ref:< a href =https://stackoverflow.com/questions/255202>如何用视觉差异程序查看'git diff'输出?
Since git diff
in powershell mostly results in a unreadable amount of whitespace or strange characters, I installed Perforce P4Merge, to handle merging and diff.
However, I can't make git diff
open the p4merge application to view the diff in. So far my .gitconfig looks like this:
[diff]
tool = p4diff
[difftool "p4diff"]
external = 'C:/PROGRA~1/Perforce/p4merge.exe "$LOCAL" "$REMOTE"'
prompt = false
[merge]
keepBackup = false
tool = p4merge
[mergetool "p4merge"]
cmd = "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
path = 'C:/PROGRA~1/Perforce/p4merge.exe'
prompt = false
keepBackup = false
keepTemporaries = false
trustExitCode = false
The paths are correct. But alas, git still attempts to present the diff in Powershell, when using git diff
.
So what's the trick to make this work?
In your command prompt, try: git config --global diff.tool p4diff
That worked for me, using a config file set up as you had described:
[diff]
tool = p4merge
[difftool "p4diff"]
external = '"C:/Program Files/Perforce/p4merge.exe" "$LOCAL" "$REMOTE"'
Running git difftool
opened p4merge as expected.
Ref: How do I view 'git diff' output with a visual diff program?
这篇关于在Windows上配置Git的diff-tool的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!