Windows上的Git Diff和Meld [英] Git Diff and Meld on Windows

查看:651
本文介绍了Windows上的Git Diff和Meld的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Meld Windows 上使用 Git C>?
我试图让它工作,我没有成功。

我安装了meld,当我从命令行调用它作为参数的两个文件时,它会很好地区分它们,所以meld安装正确。但是我无法使它与 Git Git Diff )一起工作。我使用 Git 的版本 git version 1.8.1.msysgit.1



我尝试了几件事:
我创建了一个shell脚本 meld.sh

 #!/ bin / bash 
meld.exe$ 2$ 5
echo $ 2
echo $ 5

并从git中使用它:

  [diff] 
tool = meld

[difftoolmeld]
cmd = \D:\\meld.sh\

我尝试将其作为difftool添加,如下所示:

  [diff] 
tool = meld

[difftoolmeld]
cmd = \C:\\程序文件(x86)\\\\\\\\\\\\\\\\\\\\\\\'\\\' b

或者像这样:

  [diff] 
tool = meld

[difftoolmeld]
cmd ='\/ c / Program Files(x86)/Meld/meld/meld.exe\$ PWD / $ LOCAL $ PWD / $ BASE $ PWD / $ REMOTE - 输出= $ PWD / $合并'

但它确实不起作用。我也尝试从我的shell脚本中回显第二个($ 2)和第五个($ 5)参数,并且没有输出。我也尝试过使用批处理脚本:

  meld.exe%2%5 




$ p $ meld.exe% 〜2%〜5

但它确实不起作用...有谁知道我可以通过文件 Git 的两个版本在差异到 Meld 时使用?
这非常讨厌...

解决方案

通常,您可以在Windows上找到类似于此要点,meld.exe位于 PATH 中)

  git config --global merge.tool meld 
git config --global mergetool.meld.cmd'meld。 exe \$ BASE \\$ LOCAL \\$ REMOTE \\$ MERGED \''

git config --global diff.tool meld
git config --global difftool.meld.cmd'meld.exe \$ LOCAL \\$ REMOTE\''

您可以在 Git mergetool with Meld on Windows中找到更强大的设置,但这个想法仍然是一样的。






OP在评论中报道:


对于 difftool ,您的命令会写入以下配置文件 .gitconfig




  [diff] 
tool = meld
[difftoolmeld]
cmd = meld.exe \\\\$ LOCAL \\\\\\\ \\$ REMOTE \\\\

我将它们更改为:

  [diff] 
tool = meld
[difftoolmeld]
cmd = meld.exe $ LOCAL $ REMOTE




并且一切正常。



Has anyone ever made Meld work with Git on Windows? I am trying to make it work and I have no success.

I have meld installed and when I call it from command line with two files as parameters it diffs them well so meld is installed correctly. However I can't make it work with Git (Git Diff). I use version git version 1.8.1.msysgit.1 of Git.

I have tried several things: I created a shell script meld.sh:

#!/bin/bash
meld.exe "$2" "$5"
echo $2
echo $5

and used it from git:

[diff]
    tool = meld

[difftool "meld"]
    cmd = \"D:\\meld.sh\"

I tried to add it as a difftool like this:

[diff]
    tool = meld

[difftool "meld"]
    cmd = \"C:\\Program Files (x86)\\Meld\\meld\\meld.exe\" 

or like this:

[diff]
    tool = meld

[difftool "meld"]
    cmd = '\"/c/Program Files (x86)/Meld/meld/meld.exe\" $PWD/$LOCAL $PWD/$BASE $PWD/$REMOTE --output=$PWD/$MERGED'

But it really does not seem to work. I also tried to echo the second($2) and fifth($5) parameter from my shell script and no output. I also tried using a batch script in several ways:

meld.exe %2 %5

or

meld.exe %~2 %~5

but it really does not work... Does anyone know how I can pass the two versions of the file Git uses when diffing to Meld? It's pretty annoying...

解决方案

Usually, you can find example on Windows similar to this gist, with meld.exe being in your PATH)

git config --global merge.tool meld
git config --global mergetool.meld.cmd 'meld.exe \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"'

git config --global diff.tool meld
git config --global difftool.meld.cmd 'meld.exe \"$LOCAL\" \"$REMOTE\"'

You can find a more robust settings in "Git mergetool with Meld on Windows", but the idea remains the same.


The OP reports in the comments:

For the difftool, your commands write the following configurations in .gitconfig:

[diff] 
  tool = meld 
[difftool "meld"] 
  cmd = meld.exe \\\"$LOCAL\\\" \\\"$REMOTE\\\" 

I changed them to:

[diff] 
  tool = meld 
[difftool "meld"] 
  cmd = meld.exe $LOCAL $REMOTE 

and everything worked fine.

这篇关于Windows上的Git Diff和Meld的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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