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...
Or even better if your on a lock 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 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.
For Windows 7 (or even other versions of windows) add these lines in
.gitconfig
file.Note that there is no need to use
"
for path even if it includes spaces. Just remember to use forward slashes instead of backward slashes.Another tip for users invoking diff from gitk (by right-clicking context menu item "External Diff"):
above settings may get override by gitk's preferences, in that case, change the tools in gitk's "Edit"->"preferences"->"General"->"External diff" setting.
Usually, you can find example on Windows similar to this gist, with meld.exe being in your
PATH
)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:
I changed them to:
I tried several variations of trying to set path with
git config
to no avail. Since I want to use meld from the git bash console window, what did work is to export the path to the Meld directory, restart the bash shell and lo & beholdgit difftool --tool-help
andgit mergetool --tool-help
now recognize meld and I can choose it as my preferred tool..profile
.gitconfig