msysgit安装好后处理中文是有问题的:ls中文目录/文件名乱码;提交中文的log,push到服务器上会乱码;git log查看服务器pull过来的log乱码。linux
一、ls命令列出的中文目录/文件名正确显示解决方法:git
如下配置文件的起始目录都为你安装msysgit所在的目录。shell
在Git安装目录下 \etc\git-completion.bash,加入:
bash
alias ls='ls --show-control-chars --color=auto'
二、 git log中的less乱码问题,须要添加支持utf-8;在\etc\profile,加入:
服务器
export LESSCHARSET=utf-8
三、 log注释里的中文乱码问题,须要在\etc\gitconfig 文件加入:less
[gui] encoding=utf-8 [i18n] commitencoding=GBK
乱码情景1ui
使用git add添加要提交的文件的时候,若是文件名是中文,会显示形如 274\232\350\256\256\346\200\273\347\273\223.png 的乱码。编码
解决方案:在bash提示符下输入:spa
git config --global core.quotepath false
乱码情景2code
在MsysGit中,使用git log显示提交的中文log乱码。
解决方案:设置git gui的界面编码
git config --global gui.encoding utf-8
设置 commit log 提交时使用 utf-8 编码,可避免服务器上乱码,同时与linux上的提交保持一致!
git config --global i18n.commitencoding utf-8
使得在 $ git log 时将 utf-8 编码转换成 gbk 编码,解决Msys bash中git log 乱码。
git config --global i18n.logoutputencoding gbk