问题
I am obviously overlooking something very simple here, but I am not seeing it. The command
webstorm diff ~/test.txt ~/test2.txt
runs the JetBrains graphical diff tool. I am running git 1.8.3.2 and have a git .config that includes
[diff]
tool = webstorm
[difftool "webstorm"]
cmd = webstorm diff $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE")
[difftool]
prompt = false
and when I run the command
git difftool ~/test.txt ~/test2.txt
I get the following in the terminal window:
diff --git a/home/mark/test.txt b/home/mark/test2.txt
index 7379ce2..6ce16f1 100644
--- a/home/mark/test.txt
+++ b/home/mark/test2.txt
@@ -1,2 +1,2 @@
-blah
+bluergh
What am I doing wrong / not doing?
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/23855212/git-difftool-runs-git-diff