git bash中文乱码

问题描述

使用git add添加要提交的文件的时候,如果文件名是中文,会显示形如274\232\350\256\256\346\200\273\347\273\223的乱码。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Administrator@DESKTOP-8ISAT6B MINGW64 /e/Blog/blog9 (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: "source/_posts/Hexo\346\220\255\345\273\272/Hexo\346\220\255\345\273\272.md"
modified: "source/_posts/\347\275\221\347\253\231\347\233\256\345\275\225.md"

no changes added to commit (use "git add" and/or "git commit -a")

解决方案

在bash提示符下输入:

1
git config --global core.quotepath false

core.quotepath设为false的话,就不会对0x80以上的字符进行quote。中文显示正常。

成功效果

这样中文就显示正常了:

1
2
3
4
5
6
7
8
9
10
11
Administrator@DESKTOP-8ISAT6B MINGW64 /e/Blog/blog9 (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: source/_posts/Hexo搭建/Hexo搭建.md
modified: source/_posts/网站目录.md

参考资料

https://www.cnblogs.com/EasonJim/p/8403587.html