解决命令行中 Git 显示中文文件名乱码

在用 Git 管理包含中文的文件时,会出现类似这样的 “乱码”:

1
2
3
4
5
6
7
8
9
$ 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)
"\345\271\277\345\221\212\345\220\214\346\255\245\345\271\263\345\217\260\346\216\245\345\217\243\346\226\207\346\241\2432.0.docx.new"

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

解决方法是配置 Git 的全局属性 core.quotepathfalse,即执行命令 git config --global core.quotepath false,然后再执行 git status,就可以看到中文正常显示了:

1
2
3
4
5
6
7
8
9
$ 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)
广告同步平台接口文档2.0.docx.new

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