git difftool runs git diff

試著忘記壹切 提交于 2019-11-29 11:11:49

Run:

GIT_TRACE=1 git difftool --tool-help

to print a list of diff tools that may be used with --tool, and which are not available.


Secondly I believe the following simplified example may work better:

[difftool "webstorm"]
  cmd = webstorm diff "$LOCAL" "$REMOTE"

Or by specifying the path to the binary or script, e.g.

[difftool]
  prompt = NO
  external = /usr/local/bin/diffmerge

Check the diff configuration by:

git config --get-regex diff

Or more specifically (replace webstorm with your tool name):

git config --get difftool.webstorm.cmd

If still doesn't work, test it on the new repository, e.g. by following these commands:

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

If above works, then make sure your repository config doesn't have anything unexpected, e.g.

more "$(git rev-parse --show-toplevel)"/.git/config

If you're in merge state (check by git status), you need to use mergetool instead, e.g.

git mergetool

Add -t tool to specify which tool. List available by git mergetool --tool-help.


See also 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.

I just had the same problem. My git diftool configuration has been set up in my ~/.gitconfig and has been working fine, but today weirdly git difftool worked in one repo but ran git diff in another.

Fix: I updated from git 2.11.0 to git 2.11.1 and the problem seems to have gone away.

The git 2.11.1 release notes mention fixing a difftool-related regression. The described problem isn't what I was seeing, but maybe the fix fixed it anyway.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!