设置Git编码为“UTF-8”。
在命令行输入如下命令:
$ 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 # 最后一条命令是因为git log默认使用less分页,所以需要bash对less命令进行utf-8
以上命令等效于:在“etc\gitconfig”中添加:
[core] quotepath = false
[gui] encoding = utf-8
[i18n] commitencoding = utf-8
logoutputencoding = utf-8
在“etc\profile”中添加:
export LESSCHARSET=utf-8
说明: gui.encoding = utf-8解决在$ git gui和gitk中的中文乱码。如果发现代码中的注释显示乱码,可以设置项目根目录中“git/config”文件添加如下信息: