Git qt.qpa.plugin 的 Difftool 问题:无法在“”中找到 Qt 平台插件 "cocoa"

Git Difftool problem with qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""

在我的 Mac (mac0S 10.13) 通过网站上的供应商包(而不是 Home brew)安装 P4merge 并配置我的 [=26= 后,我无法 'git difftool' 启动 P4merge ] 文件如下:

[user]
name = (my name)
email = (my email)
[core]
editor = mate -w
[alias]
hist = log --all --graph --decorate --oneline
[diff]
tool = p4merge
[difftool "p4merge"]
path = /Applications/p4merge.app/Contents/MacOs/p4merge
[difftool]
prompt = false
[merge]
tool = p4merge
[mergetool "p4merge"]
path = /Applications/p4merge.app/Contents/MacOs/p4merge
[mergetool]
prompt = false

当我 运行 'git difftool' 时,我没有打开 P4merge,而是收到一条警告说“p4merge 意外退出”,并在终端中显示以下消息:

qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
/usr/local/Cellar/git/2.26.0/libexec/git-core/mergetools/p4merge: line 1: 22662 Abort trap: 6 "$merge_tool_path" "$LOCAL" "$REMOTE"

我已经尝试卸载并重新安装 p4merge。如果我双击该应用程序并且不尝试从 git.

中使用它,P4merge 就会工作

谢谢。这是我的第一期,所以如果我发错了,请告诉我!有很多类似的问题,但大多数似乎与Python有关,而不是与我的相同。

挖牛

这里的答案在于在 git 配置文件中更改 git difftool 的路径。我在阅读 Command Line P4 merge on MacOsX 后想到了这个。更改 /Applications/p4merge.app/Contents/Resources/launchp4merge 的路径会导致“git diff”和“git difftool”按预期工作,第一个显示 git 状态的差异终端中的文件,第二个在 P4merge 中打开两个文件。

gitcofig --global