ChatGPT解决这个技术问题 Extra ChatGPT

How to set Meld as git mergetool

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.

Copy paste parts of .gitconfig from: marcin-chwedczuk.github.io/use-meld-as-git-merge-diff-tool
Related: "Configuring diff tool with .gitconfig": stackoverflow.com/a/6412645/4561887 (for meld, just replace vimdiff with meld in this answer)
Please comment and vote to upstream issue so future user won’t even need to worry about this.

D
Declan McKenna

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

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.exe
@abergmeier Ok, I have included your comment in the answer for more visibility.
@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.
FYI, on Mac OSx: install homebrew, then: $ brew install homebrew/x11/meld $ git config --global merge.tool meld $ git config --global diff.guitool meld
@CenterOrbit OK, I have included your comment in the answer for more visibility.
o
oldwizard

This worked for me on Windows 8.1 and Windows 10.

git config --global mergetool.meld.path "/c/Program Files (x86)/meld/meld.exe"

git config --global mergetool.meld.path "c:\Program Files (x86)\meld\meld.exe" when using PowerShell
sometimes you may to restart your git gui after you git config (to take a change)
T
Tomasz Maj

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\"

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.
Hello, I've tried it and it works great. In my case, it was the 'cmd' which was missing to properly call meld
Meld didn't save merged files correctly for me when using this command-line template. See stackoverflow.com/a/40777256/768795 for an answer that works.
d
dbn

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

C
Community

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

Y
Yohanim

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


j
jozxyqk

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.


S
Sylvain Martin

For windows add the path for meld is like below:

 git config --global mergetool.meld.path C:\\Meld_run\\Meld.exe

S
Sameera De Silva

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 = doe@john.com
[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 

B
Bhavesh Gupta

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