Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git & WinMerge (msysgit)

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.

like image 731
Anthony Compton Avatar asked Oct 28 '10 16:10

Anthony Compton


1 Answers

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.

like image 173
VonC Avatar answered Sep 25 '22 02:09

VonC