1 Answers
Best Answer
请把Git控制台的默认输出改为gbk编码:
git config --global i18n.logoutputencoding gbk
测试过程:
安装完git,提交一个包含中文的描述的changes,在PS中查看log
PS> & "C:\Program Files (x86)\Git\bin\git.exe" log
commit 54e5e2497267c8f04235dffbcd76f98ebfe0ae4f
Author: Baozhen Li <Baozhen Li>
Date: Mon Jun 27 23:33:24 2016 +0800
PowerShell中文博客测试
Signed-off-by: Baozhen Li <Baozhen Li>
commit 80020d57fac60b22872f4b202c7ef8977348a389
Author: Baozhen Li <Baozhen Li>
Date: Mon Jun 27 23:31:04 2016 +0800
Signed-off-by: Baozhen Li <Baozhen Li>
保存到变量,再测试,发现中文字符乱码:
PS> $s=& "C:\Program Files (x86)\Git\bin\git.exe" log
PS> $s
commit 54e5e2497267c8f04235dffbcd76f98ebfe0ae4f
Author: Baozhen Li <Baozhen Li>
Date: Mon Jun 27 23:33:24 2016 +0800
PowerShell涓枃鍗氬娴嬭瘯
Signed-off-by: Baozhen Li <Baozhen Li>
commit 80020d57fac60b22872f4b202c7ef8977348a389
Author: Baozhen Li <Baozhen Li>
Date: Mon Jun 27 23:31:04 2016 +0800
Signed-off-by: Baozhen Li <Baozhen Li>
打开git bush,运行上面的配置:
git config --global i18n.logoutputencoding gbk
再次测试:
PS> $a=& "C:\Program Files (x86)\Git\bin\git.exe" log
PS> $a
commit 54e5e2497267c8f04235dffbcd76f98ebfe0ae4f
Author: Baozhen Li <Baozhen Li>
Date: Mon Jun 27 23:33:24 2016 +0800
PowerShell中文博客测试
Signed-off-by: Baozhen Li <Baozhen Li>
commit 80020d57fac60b22872f4b202c7ef8977348a389
Author: Baozhen Li <Baozhen Li>
Date: Mon Jun 27 23:31:04 2016 +0800
Signed-off-by: Baozhen Li <Baozhen Li>