Git Windows下配置Merge工具DiffMerge

参考出处:http://coding4streetcred.com/blog/post/Configure-DiffMerge-for-Your-Git-DiffTool

DiffMerge官方提供的方法在Windows系统下实现无效。。 Google了个更简便的方法,亲测有效,

1、下载DiffMerge

http://sourcegear.com/diffmerge/downloads.php,楼主选择的是 Windows Installer (64bit),安装直接下一步,这一版只能安装在C盘

2、创建启动DiffMerge脚本

1)在Git的安装路径的\cmd路径下创建以下两个脚本

(如何创建:先创建TXT,粘贴进去,再改txt名字为.sh的脚本名字)
注意:前面的路径名为安装后的DiffMerge.exe的实际路径名,不然git就找不到了,楼主的为”C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe”

Git Windows下配置Merge工具DiffMerge_第1张图片

(1)git-difftool-diffmerge-wrapper.sh

# place this file in the Windows Git installation directory /cmd folder
# be sure to add the ../cmd folder to the Path environment variable

# diff is called by git with 7 parameters:
# path old-file old-hex old-mode new-file new-hex new-mode

"C:/Program Files (x86)/SourceGear/DiffMerge/DiffMerge.exe" "$1" "$2" | cat

(2)git-mergetool-diffmerge-wrapper.sh

# place this file in the Windows Git installation directory /cmd folder
# be sure to add the ../cmd folder to the Path environment variable

# passing the following parameters to mergetool:
# local base remote merge_result

"C:/Program Files (x86)/SourceGear/DiffMerge/DiffMerge.exe" "$1" "$2" "$3" --result="$4" --title1="Mine" --title2="Merge" --title3="Theirs"

2)将\cmd设置环境变量,方便找

Git Windows下配置Merge工具DiffMerge_第2张图片

3、黑掉Git配置文件

找到.gitconfig文件(路径在Windows“用户”路径下),

Git Windows下配置Merge工具DiffMerge_第3张图片
TXT编辑,相关内容用下面的替换

[merge]
    tool = diffmerge
[diff]
    tool = diffmerge
[mergetool]
    keepBackup = false
[mergetool "diffmerge"]
    cmd = git-mergetool-diffmerge-wrapper.sh "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
[difftool "diffmerge"]
    cmd = git-difftool-diffmerge-wrapper.sh "$LOCAL" "$REMOTE"

4、OK

当merge出现冲突的时候,输入
git mergetool
diffmerge就出来啦
Git Windows下配置Merge工具DiffMerge_第4张图片

你可能感兴趣的:(VS2013,DiffMerge,git,windows)