Skip to content

Instantly share code, notes, and snippets.

@zfkingth
Last active December 26, 2017 10:06
Show Gist options
  • Save zfkingth/fe05ca93e586d6acf8d86015630bae1b to your computer and use it in GitHub Desktop.
Save zfkingth/fe05ca93e586d6acf8d86015630bae1b to your computer and use it in GitHub Desktop.
git 中文 乱码 utf-8 diff merge tool 配置
第一步
将git-diff-wrapper.sh 文件放入c:\Program Files\Git\mingw64\bin 目录中
git-diff-wrapper.sh 文件的内容
#!/bin/sh
#diff is called by git with 7 parameters:
#path old-file old-hex old-mode new-file new-hex new-mode
TortoiseGitMerge -base:"$2" -theirs:"$5"
第二步,执行下列命令
#modify,......
# 全局提交用户名与邮箱
git config --global user.name "zfking"
git config --global user.email zfking@gmail.com
#执行以下脚本(再别人的基础上修改)
# 中文编码支持
echo "export LESSCHARSET=utf-8" > $HOME/.profile
git config --global core.quotepath false # 显示 status 编码
git config --global gui.encoding utf-8 # 图形界面编码
git config --global i18n.commit.encoding utf-8 # 提交信息编码
git config --global i18n.logoutputencoding utf-8 # 输出 log 编码
export LESSCHARSET=utf-8
# 全局编辑器,提交时将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 'TortoiseGitMerge -base:"$LOCAL" -theirs:"$REMOTE"'
git config --global difftool.prompt false
# 合并工具配置
git config --global merge.tool tortoise
git config --global mergetool.tortoise.cmd 'TortoiseGitMerge -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 config --global alias.co checkout
git config --global alias.br branch
git config --global alias.st status
git config --global alias.ci commit
# 取消 $ git gui 的中文界面,改用英文界面更易懂
if [ -f "/share/git-gui/lib/msgs/zh_cn.msg" ]; then
rm /share/git-gui/lib/msgs/zh_cn.msg
fi
#执行完成后,再git bash点右键,Options->Text面板中Local选择 zh_cn,characterset选择UTF-8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment