您的位置:首页 > 其它

git status输出, 中文文件名显示为转义字符编码(乱码)

2017-05-05 10:44 1161 查看

问题

UTF-8(中文)字符显示为转义字符(乱码)

演示

$ touch 测试.txt

$ git version
git version 2.9.3

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)

"\346\265\213\350\257\225.txt"

nothing added to commit but untracked files present (use "git add" to track)


原因

默认情况下, git不处理UTF-8文件名

解决办法

git config --global core.quotepath false


补充

git status
, 中文显示为八进制转义编码

➜  ~ python3
Python 3.5.2 (default, Sep 14 2016, 11:28:32)
[GCC 6.2.1 20160901 (Red Hat 6.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> s='测试'
>>> s.encode('utf-8')
b'\xe6\xb5\x8b\xe8\xaf\x95'
>>> s.encode('utf-8')[0]
230
>>> oct(s.encode('utf-8')[0])
'0o346'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: