How to set Meld as git mergetool
Asked Answered
B

10

115

I've set:

git config --global merge.tool meld
git config --global mergetool.meld.path c:/Progra~2/meld/bin/

On "git mergetool" it writes:

Hit return to start merge resolution tool (meld):
The merge tool meld is not available as 'c:/Progra~2/meld/bin/'

I have tried also:

  • /c/Progra~2/meld/bin/
  • "/c/Program files (x86)/meld/bin/"
  • "c:/Program files (x86)/meld/bin/"

result is the same.

when I go to C:/Program files (x86)/meld/bin/ and run

python meld

the tool runs.

Burchfield answered 18/10, 2012 at 14:2 Comment(4)
see also https://mcmap.net/q/16906/-which-version-of-the-git-file-will-be-finally-used-local-base-or-remoteReturn
Copy paste parts of .gitconfig from: marcin-chwedczuk.github.io/use-meld-as-git-merge-diff-toolEby
Related: "Configuring diff tool with .gitconfig": https://mcmap.net/q/14804/-configuring-diff-tool-with-gitconfig (for meld, just replace vimdiff with meld in this answer)Heartwarming
Please comment and vote to upstream issue so future user won’t even need to worry about this.Phyliciaphylis
S
89

You could use complete unix paths like:

PATH=$PATH:/c/python26
git config --global merge.tool meld
git config --global mergetool.meld.path /c/Program files (x86)/meld/bin/meld

This is what is described in "How to get meld working with git on Windows"

Or you can adopt the wrapper approach described in "Use Meld with Git on Windows"

# set up Meld as the default gui diff tool
$ git config --global  diff.guitool meld

# set the path to Meld
$ git config --global mergetool.meld.path C:/meld-1.6.0/Bin/meld.sh

With a script meld.sh:

#!/bin/env bash
C:/Python27/pythonw.exe C:/meld-1.6.0/bin/meld $@

abergmeier mentions in the comments:

I had to do:

git config --global merge.tool meld
git config --global mergetool.meld.path /c/Program files (x86)/Meld/meld/meldc.exe

Note that meldc.exe was especially created to be invoked on Windows via console. Thus meld.exe will not work properly.


CenterOrbit mentions in the comments for Mac OS to install homebrew, and then:

brew cask install meld
git config --global merge.tool meld
git config --global  diff.guitool meld
Subtlety answered 18/10, 2012 at 14:57 Comment(8)
For me, I had to do: git config --global merge.tool meld git config --global mergetool.meld.path /c/Program files (x86)/Meld/meld/meldc.exeOlivas
@Olivas Ok, I have included your comment in the answer for more visibility.Subtlety
@abergmeier's solution works. Also, on windows git bash, if you do tab key, it will suggest the path so its easy to get it right.Domoniquedomph
FYI, on Mac OSx: install homebrew, then: $ brew install homebrew/x11/meld $ git config --global merge.tool meld $ git config --global diff.guitool meldAle
@Ale OK, I have included your comment in the answer for more visibility.Subtlety
meldc is not available now @OlivasNissen
@SmartManoj From meldmerge.org/news.html, it could be named now (10 years after my initial writings) meldconsole.exe: meldmerge.org/news.htmlSubtlety
@Subtlety And it is a dev version.Nissen
H
28

This worked for me on Windows 8.1 and Windows 10.

git config --global mergetool.meld.path "/c/Program Files (x86)/meld/meld.exe"
Herbert answered 15/7, 2015 at 7:40 Comment(2)
git config --global mergetool.meld.path "c:\Program Files (x86)\meld\meld.exe" when using PowerShellGoings
sometimes you may to restart your git gui after you git config (to take a change)Angelikaangelina
F
17

meld 3.14.0

[merge]
    tool = meld
[mergetool "meld"]
    path = C:/Program Files (x86)/Meld/Meld.exe
    cmd = \"C:/Program Files (x86)/Meld/Meld.exe\" --diff \"$BASE\" \"$LOCAL\" \"$REMOTE\" --output \"$MERGED\"
Fidole answered 27/11, 2015 at 10:20 Comment(3)
Please be aware that this is an abandoned question. I haven't dealt with merge tools for a long time, so even if your answer is the best, I cannot prove it and mark as an answer.Burchfield
Hello, I've tried it and it works great. In my case, it was the 'cmd' which was missing to properly call meldAlgonquin
Meld didn't save merged files correctly for me when using this command-line template. See https://mcmap.net/q/17544/-git-extensions-and-meld-merge for an answer that works.Woebegone
A
9

After installing it http://meldmerge.org/ I had to tell git where it was:

git config --global merge.tool meld
git config --global diff.tool meld
git config --global mergetool.meld.path “C:\Program Files (x86)\Meld\meld.exe”

And that seems to work. Both merging and diffing with “git difftool” or “git mergetool”

If someone facing issue such as Meld crash after starting (problem indication with python) then you need to set up Meld/lib to your system environment variable as bellow C:\Program Files (x86)\Meld\lib

Angelikaangelina answered 5/11, 2019 at 11:13 Comment(0)
C
6

I think that mergetool.meld.path should point directly to the meld executable. Thus, the command you want is:

git config --global mergetool.meld.path c:/Progra~2/meld/bin/meld
Chatelaine answered 1/2, 2013 at 19:8 Comment(0)
C
5

None of the other answers here worked for me, possibly from trying a combination of all of them. I was able to adapt this accepted answer to work with meld. This is now working for me with git 1.9.4, meld 3.14.0, and windows 8.1.

Edit ~/.gitconfig to look like:

[diff]
    tool = meld
    guitool = meld
[mergetool "meld"]
    path = c:/Program Files (x86)/Meld/Meld.exe
[difftool "meld"]
    path = c:/Program Files (x86)/Meld/Meld.exe
Cusack answered 24/10, 2015 at 5:15 Comment(0)
G
3

It took a few permutations to get meld working on windows for me. This is my current .gitconfig:

[merge]
    conflictstyle = diff3
    tool = meld
[mergetool "meld"]
    cmd = \"C:\\Program Files (x86)\\Meld\\Meld.exe\" --auto-merge \"$LOCAL\" \"$BASE\" \"$REMOTE\" --output \"$MERGED\"

Linux:

[merge]
    conflictstyle = diff3
    tool = meld
[mergetool "meld"]
    cmd = meld --auto-merge $LOCAL $BASE $REMOTE --output=$MERGED --diff $BASE $LOCAL --diff $BASE $REMOTE

I believe adding conflictstyle = diff3 changes the inline text to include BASE contents in the output file before meld gets to it, which might give it a head start. Not sure.

Now, since I already noted Meld supports three-way merging, there is another option. When “diff3” git conflict style is set, Meld prints “(??)” on the line showing the content from BASE. source

A few meld command line features I really like:

  • --auto-merge does a great job at choosing the right thing for you (it's not bulletproof, but I consider the time saved to be worth any risk).

  • You can add extra diff windows in the same command. E.g.:

    --diff $BASE $LOCAL --diff $BASE $REMOTE

    will add two more tabs with the local and incoming patch diffs. These can be quite useful to see separately from the 3 way view to see separate diffs from the base in each branch. I could't get this working on windows though.

  • Some version of meld allow you to label tabs with --label. This was more important before git fixed the names of the files passed to meld to include local/base/remote.

  • The order of --diff can affect the tab order. I had trouble in some older versions that were putting the additional diffs first, when the main 3 way diff is far more frequently used.

Gazpacho answered 10/11, 2020 at 19:10 Comment(0)
M
1

Adding below lines in my .gitconfig file in C:\Users\username, solved my issue for 3.20.3 in Windows 10.

[user]
    name = doe
    email = [email protected]
[core]
longpaths = true
[diff]
    tool = meld
[difftool "meld"]
    path=C:/Program Files/Meld/Meld.exe
[difftool]
    prompt = false
[merge]
    tool = meld
[mergetool "meld"]
    path=C:/Program Files/Meld/Meld.exe
[mergetool]
    prompt = false
    KeepBackup = false 
Mondrian answered 29/4, 2021 at 9:44 Comment(0)
R
0

For windows add the path for meld is like below:

 git config --global mergetool.meld.path C:\\Meld_run\\Meld.exe
Rift answered 7/6, 2017 at 9:31 Comment(0)
S
-1

git config --global merge.tool meld git config --global mergetool.meld.path c:/Progra~2/meld/Meld/

Shade answered 21/2, 2022 at 5:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.