发生背景
项目没打算国际化, commit message 全部是中文。
以前一直用 VS Code 做 git 代理界面,现在一看 git log:
$ git log
commit 44ddf9802fe149f12ff3986ffc80b33802470e4a (origin/login-api, feature/login-api)
Author: kaikaibenkai <kaikai_miniworld@outlook.com>
Date: Sat Dec 3 09:06:53 2022 +0800
<E5><8C><88><E6><83><E6><8C><E5><A0><81><99><E5><BD><E5><E9><88>
解决方案
首先,让 git 知道怎么解码中文( utf-8 ):
git config --global i18n.commitencoding utf-8
git config --global i18n.logoutputencoding utf-8
然后,让系统知道怎么解码中文:
$ export LESSCHARSET=utf-8
最后,设置 Git Bash 解码方式:
再看看 log ,问题解决。
( VS Code 1.74 修改了中文字体,在终端里超好看)