How can I make WinMerge my git mergetool?

2019-01-10 06:28发布

I'm trying to integrate WinMerge with Git as I've seen others done before on Windows 7 Ultimate.

I've followed the following steps, but an error continues to show up when I do a git mergetool which defaults to vimdiff.

Created a file called winmerge.sh in the root directory of git: C/Program Files (x86)/Git/ with: WinMergeU is the correct location.

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

and used the following commands.

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

The error shows up as:

git config option merge.tool set to unknown tool: winmerge

9条回答
Viruses.
2楼-- · 2019-01-10 07:13

Your path is incorrect, it should be "/c/Program Files (x86)/WinMerge/WinMergeU.exe".

You're running in a shell script environment, not native windows command prompt.

查看更多
老娘就宠你
3楼-- · 2019-01-10 07:16

Here's mine (in %userprofile%\.gitconfig, or ~/.gitconfig on *nix), no wrapper (Win 7 Home Pro):

[diff]
    tool = winmerge
[difftool "winmerge"]
    cmd = c:/path/to/winmergeu.exe -e -u -x -wl -wr -dl "base" -dr "mine" \"$LOCAL\" \"$REMOTE\"
查看更多
4楼-- · 2019-01-10 07:18

Git 2.5+ (Q2 2015) will include Winmerge as a known git mergetool!

If Winmerge is in your %PATH%, a git config merge.tool winmerge is all you need to do!
(It works for diff tool too: git config diff.tool winmerge)

See commit 3e4f237 by David Aguilar (davvid), 20 May 2015.
(Merged by Junio C Hamano -- gitster -- in commit 324a9f4, 01 Jun 2015)
Helped-by: Philip Oakley (PhilipOakley), Johannes Schindelin (dscho), Sebastian Schuberth (sschuberth), SZEDER Gábor (szeder)

All the config is now done for you directly in Git itself, with mergetools/winmerge:

  • diff command: "$merge_tool_path" -u -e "$LOCAL" "$REMOTE"
  • merge command: "$merge_tool_path" -u -e -dl Local -dr Remote "$LOCAL" "$REMOTE" "$MERGED"

mergetools: add winmerge as a builtin tool

Add a winmerge scriptlet with the commands described in this thread, so that users can use winmerge without needing to perform any additional configuration.

查看更多
登录 后发表回答