Git在Windows环境下配置Diff以及Merge工具---DiffMerge

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Git在Windows环境下配置Diff以及Merge工具---DiffMerge相关的知识,希望对你有一定的参考价值。

参考出处:http://coding4streetcred.com/blog/post/Configure-DiffMerge-for-Your-Git-DiffTool
主要转自:http://blog.csdn.net/u010232305/article/details/51767887

1、下载DiffMerge

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

2、创建启动DiffMerge脚本

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

技术分享

git-difftool-diffmerge-wrapper.sh内容为

1 # place this file in the Windows Git installation directory /cmd folder
2 # be sure to add the ../cmd folder to the Path environment variable
3 
4 # diff is called by git with 7 parameters:
5 # path old-file old-hex old-mode new-file new-hex new-mode
6 
7 "C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe" "$1" "$2" | cat

git-mergetool-diffmerge-wrapper.sh内容为

1 # place this file in the Windows Git installation directory /cmd folder
2 # be sure to add the ../cmd folder to the Path environment variable
3 
4 # passing the following parameters to mergetool:
5 # local base remote merge_result
6 
7 "C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe""$1""$2""$3" --result="$4" --title1="Mine" --title2="Merge" --title3="Theirs"

注意:其中的路径名为安装后的DiffMerge.exe的实际路径名,楼主的为”C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe”

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

将git程序的cmd目录加入环境变量Path,楼主的为"C:\Program Files\Git\cmd"

技术分享

3、修改Git配置

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

技术分享
upsert以下内容:

 1 [merge]
 2     tool = diffmerge
 3 [diff]
 4     tool = diffmerge
 5 [mergetool]
 6     keepBackup = false
 7 [mergetool "diffmerge"]
 8     cmd = git-mergetool-diffmerge-wrapper.sh "$LOCAL" "$BASE" "$REMOTE" "$MERGED"
 9 [difftool "diffmerge"]
10     cmd = git-difftool-diffmerge-wrapper.sh "$LOCAL" "$REMOTE"

4、OK

当merge出现冲突的时候,输入 
git mergetool 
diffmerge就出来啦 
技术分享

 

以上是关于Git在Windows环境下配置Diff以及Merge工具---DiffMerge的主要内容,如果未能解决你的问题,请参考以下文章

git diff 配置 meld diff

Windows下GIT配置BeyondCompare为默认差异比较工具和合并工具

Windows环境下的git与github配置

在windows和Linux下的Git环境搭建

windows配置jdk环境变量mysql环境变量tomcat环境变量maven环境变量git环境变量node环境变量

Windows下Git的安装及配置