如何在msysgit中配置配置使用diffmerge,作为diff/merge的工具

一、在电脑上安装了msysgit和diffmerge

msysgit的下载地址:http://msysgit.github.io

diffmerge的下载地址:http://sourcegear.com/diffmerge/downloads.php

安装msysgit和diffmerge。

二、.在电脑的任何一个地方新建一个文件,把下面的shell脚本复制进去,保存,并重命名为gitconfig

在当前目录右键-->Git Bash,输入gitconfig执行


<pre name="code" class="plain">#!/bin/sh

# 中文编码支持
echo "export LESSCHARSET=utf-8" > $HOME/.profile
git config --global gui.encoding utf-8
git config --global i18n.commitencoding utf-8
git config --global i18n.logoutputencoding gbk

# 全局编辑器,提交时将COMMIT_EDITMSG编码转换成UTF-8可避免乱码
#git config --global core.editor "D:\Program Files (x86)\Notepad++\notepad++.exe"

# 差异工具配置
git config --global diff.external git-diff-wrapper.sh
git config --global diff.tool diffmerge
git config --global difftool.diffmerge.cmd 'sgdm "$LOCAL" "$REMOTE"'

# 合并工具配置
git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmd 'sgdm --merge --result="$MERGED" "$LOCAL" "$BASE" "$REMOTE"'
git config --global mergetool.diffmerge.trustExitCode true

# 别名设置
git config --global alias.dt difftool
git config --global alias.mt mergetool
git config --global alias.cit citool

# 取消 $ git gui 的中文界面,改用英文界面更易懂
if [ -f "/share/git-gui/lib/msgs/zh_cn.msg" ]; then
rm /share/git-gui/lib/msgs/zh_cn.msg
fi

 

sgdm是diffmerge的程序名。

上面的shell脚本主要有做的事有:

1.支持中文编码。(解决msysgit中的乱码问题)。

2.diff工具的配置

3.merge工具的配置

4.设置difftool,mergetool的别名

5.将中文界面改为英文界面

还需要用到notepad++文本编辑器,可以从下载http://notepad-plus-plus.org/download/v6.7.3.html

三、在git的安装路径的cmd文件夹中(例:D:\Program Files (x86)\Git\cmd)新建一个名为git-diff-wrapper.sh的文件,并复制进去下面的shell脚本

#!/bin/sh

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

sgdm "$2" "$5"

四、加入环境变量

把diffmerge的安装路径加入到PATH中,否则需要将shell脚本中的sgdm用"C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe"(根据diffmerge的安装路径修改)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值