13

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

 3 years ago
source link: https://www.boris1993.com/tools/git/git-commandline-unescape-chinese-characters.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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

2020-02-10 2020-12-10工具Git

174 0

在用 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)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK