跑:
GIT_TRACE=1 git difftool --tool-help
打印可与 一起使用但不可用的差异工具列表--tool
。
其次,我相信以下简化示例可能会更好:
[difftool "webstorm"]
cmd = webstorm diff "$LOCAL" "$REMOTE"
或者通过指定二进制文件或脚本的路径,例如
[difftool]
prompt = NO
external = /usr/local/bin/diffmerge
通过以下方式检查差异配置:
git config --get-regex diff
或更具体地说(替换webstorm
为您的工具名称):
git config --get difftool.webstorm.cmd
如果仍然不起作用,请在新存储库上对其进行测试,例如通过以下命令:
mkdir ~/git_test && cd ~/git_test
git init && touch file && git add file && git commit -m'Adds file' -a
echo changed >> file
GIT_TRACE=1 git difftool
如果上述方法有效,请确保您的存储库配置没有任何意外,例如
more "$(git rev-parse --show-toplevel)"/.git/config
如果您处于合并状态(检查git status
),则需要使用mergetool
,例如
git mergetool
添加-t tool
以指定哪个工具。可用的列表git mergetool --tool-help
。
另见man git-difftool
:
CONFIG VARIABLES
git difftool falls back to git mergetool config variables when the difftool equivalents have not been
defined.
diff.tool
The default diff tool to use.
diff.guitool
The default diff tool to use when --gui is specified.
difftool.<tool>.path
Override the path for the given tool. This is useful in case your tool is not in the PATH.
difftool.<tool>.cmd
Specify the command to invoke the specified diff tool.
See the --tool=<tool> option above for more details.
difftool.prompt
Prompt before each invocation of the diff tool.