richardmyu / blog

个人(issues)博客
https://github.com/richardmyu/blog/issues
MIT License
0 stars 0 forks source link

power shell 中 `git log` 中文显示问题 #11

Open richardmyu opened 3 years ago

richardmyu commented 3 years ago

今天试着使用 power shell 来提交代码,然后使用 git log 查看提交记录的时候,发现无法显示中文,确切地说是中文被显示为对应 ASCII 字符:

 add(docs): <E5><A2><9E><E5><8A><A0> linux-<E7><8E><AF><E5><A2><83><E5><8F><98><E9><87><8F><E9><83><A8><E5><88><86><E8><AF><BE><E7><A8><8B><E7><AC><94><E8><AE><B0>

通过查询,阅读 powershell中git log的中文问题PowerShell | git log 中文乱码问题解决 解决了这个问题。

第一步,在 power shell 中输入以下命令:

git config --global core.quotepath false
git config --global gui.encoding utf-8
git config --global i18n.commit.encoding utf-8
git config --global i18n.logoutputencoding utf-8
$env:LESSCHARSET='utf-8'

第二步,添加环境变量:

setx LESSCHARSET 'utf-8'