搞定Git中文乱码、用TortoiseMerge实现Diff/Merge

本文提供了一个脚本,用于解决中文乱码问题,配置图形化的差异和合并工具TortoiseMerge,并还原Git GUI的英文界面。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

步骤:
1. 下载: http://loaden.googlecode.com/files/gitconfig.7z
2. 解压到:< MsysGit 安装目录>/cmd/,例如:D:\Program Files\Git\cmd
3. 进入Bash,执行gitconfig

搞定什么了?
看看gitconfig的内容先:
Perl code
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
 
# 全局提交用户名与邮箱
git config --global user.name  "Yuchen Deng"
git config --global user.email 邮箱名 @gmail .com
 
# 中文编码支持
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 notepad2
 
# 差异工具配置
git config --global diff.external git-diff-wrapper.sh
git config --global diff.tool tortoise
git config --global difftool.tortoise.cmd  'TortoiseMerge -base:"$LOCAL" -theirs:"$REMOTE"'
git config --global difftool.prompt false
 
# 合并工具配置
git config --global merge.tool tortoise
git config --global mergetool.tortoise.cmd  'TortoiseMerge -base:"$BASE" -theirs:"$REMOTE" -mine:"$LOCAL" -merged:"$MERGED"'
git config --global mergetool.prompt false
 
# 别名设置
git config --global alias.dt difftool
git config --global alias.mt mergetool
 
# 取消 $ git gui 的中文界面,改用英文界面更易懂
if  [ -f  "/share/git-gui/lib/msgs/zh_cn.msg"  ]; then
rm /share/git-gui/lib/msgs/zh_cn.msg
fi


这个脚本解决了:
1. 中文乱码
2. 图形化Diff/Merge
3. 还原英文界面,更好懂
其中最有价值的,就是Git的Diff/Merge外部工具TortoiseMerge配置。
安装MsysGit后,一个命令即可完成配置。
适用于MsysGit安装版与绿色版。

网上关于为Git配置TortoiseMerge来进行diff和merge的介绍几乎没有(反正我没有搜索到),但我认为TortoiseMerge是最好用的,单文件(一个可执行程序,绿色版,下载地址: http://sourceforge.net/projects/tortoisesvn/files/Tools/1.6.7/TortoiseDiff-1.6.7.zip/download ),实在是绝配!

为什么不使用TortoiseGit?他们不是集成了TortoiseMerge吗?
理由:TortoiseGit只有Windows才有,我更喜欢git gui,结合gitk,跨平台实在相同的操作方式,更爽!
如果您离不开TortoiseGit,这篇文章就直接无视吧。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值