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 the 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... How can I pass the two versions of the file Git
uses when diffing to Meld?
It's pretty annoying...
Meld is a visual diff and merge tool targeted at developers. Meld helps you compare files, directories, and version controlled projects. It provides two- and three-way comparison of both files and directories, and supports many version control systems including Git, Mercurial, Bazaar, CVS and Subversion.
Usually, you can find an 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 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.
Or even better, if you're on a locked-down system where fooling with the path is not allowed or you just don't want to pollute your path space, you can just put in the full path to Meld.
I also prefer my current working code copy to show up on the left, so I swapped the $REMOTE and $LOCAL arguments. Also mind the conversions of \ to / and don't for get to escape the double quotes.
[diff]
tool = meld
[difftool "meld"]
cmd = \"C:/Program Files (x86)/Meld/meld/meld.exe\" $REMOTE $LOCAL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With