views:

45

answers:

1

I've read about a bajillion Q&A's on this very topic, and followed all the instructions to the letter. But I'm still getting headaches trying to set up Git to diff and merge using WinMerge.

I've taken the following steps using the Git terminal:

git config --global diff.tool winmerge
git config --global difftool.winmerge.cmd "winmerge.sh \"$LOCAL\" \"$REMOTE\""
git config --global difftool.prompt false

I've also set up a script in a directory included in my PATH variable that reads:

#!/bin/sh
echo Launching WinMergeU.exe: $1 $2
"C:/Program Files/WinMerge/WinMergeU.exe" git /e /u /dl "Base" /dr "Mine" "$1" "$2""

When I execute

git mergetool

In the Git terminal, I see:

Merging:
first.txt

Normal merge conflict for 'first.txt':
  {local}: modified
  {remote}: modified
Launching WinMergeU.exe:

So it seems to me that the $LOCAL and $REMOTE variables aren't passing anything into the winmerge.sh script. What am I doing wrong here? I have to assume its in the configuration part.

+1  A: 

Compared to my previous answer (or this one, or that one), your steps include an extra double-quote at the end of winmerge.sh script

    #!/bin/sh
    echo Launching WinMergeU.exe: $1 $2
    "C:/Program Files/WinMerge/WinMergeU.exe" 
      git /e /u /dl "Base" /dr "Mine" "$1" "$2""
                                               ^
                                               |
                                    (this shouldn't be here)

That being said, those answers were about difftool using winmerge, which doesn't support 3-way merge (there is only local and remote, no base).

For a true merge tool, I would recommend kdiff3 (as in "Is it possible for git-merge to ignore line-ending differences?") or araxis (as described in "How to set Araxis as diff / merge tool for MSYS git?"), where you can see the three variables (local, remote and base) used.

VonC
Could you fix your link?
erjiang
@erjiang: links fixed, and important comment about three-way merge tools added.
VonC