git difftool运行git diff [英] git difftool runs git diff

查看:146
本文介绍了git difftool运行git diff的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我显然在这里忽略了一些非常简单的东西,但我没有看到它。命令

  webstorm diff〜/ test.txt〜/ test2.txt 

运行JetBrains图形化比较工具。我正在运行git 1.8.3.2,并且有一个包含

  [diff] 
tool = webstorm $的git .config。 $ cd $(dirname$ LOCAL)&& pwd)/ $(basename$ LOCAL)$($) $ REMOTE)&& pwd)/ $(basename$ REMOTE)
[difftool]
prompt = false

,当我运行命令时

  git difftool〜/ test.txt〜 /test2.txt 

我在终端窗口中看到以下内容:

  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

我做错了什么/没做?

解决方案

运行:

  GIT_TRACE = 1 git difftool --tool-help 

to prin ta可以与 - tool 一起使用的diff工具列表,以及哪些不可用。




其次,我相信以下简化示例可能会更好:

  [difftoolwebstorm] 
cmd = webstorm diff$ LOCAL$ REMOTE

或者通过指定路径到二进制或脚本,例如

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






检查diff配置:

  git config --get-regex diff 

或者更具体地说(用你的工具名称替换 webstorm ):

  git config --get difftool.webstorm.cmd 






如果仍然无效,请在新的存储库上进行测试,例如通过以下命令:

  mkdir〜/ git_test&& cd〜/ git_test 
git init&&触摸文件&& git add file&& git commit -m'添加文件'-a
echo改变>>文件
GIT_TRACE = 1 git difftool

如果以上工作正常,请确保您的存储库配置不会没有任何意想不到的,例如

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






如果您处于合并状态通过 git status ),您需要使用 mergetool ,例如

  git mergetool 

添加 -t工具来指定哪个工具。列表可用 git mergetool --tool-help






另见 man git-difftool

  CONFIG VARIABLES 
当difftool等价物未被
定义时,git difftool会回退到git mergetool配置变量。

diff.tool
要使用的默认差异工具。

diff.guitool
指定--gui时使用的缺省diff工具。

difftool。< tool> .path
覆盖给定工具的路径。如果您的工具不在PATH中,这非常有用。

difftool。< tool> .cmd
指定要调用指定diff工具的命令。

请参阅--tool =< tool>上面的选项了解更多详情。

difftool.prompt
每次调用diff工具前提示。


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?

解决方案

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.

这篇关于git difftool运行git diff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆