[GIT] GIT中文文件路径显示为转义字符的一种解决办法

陪她去流浪 桃子 2017年06月26日 阅读次数:3191

在 GIT 中,它把非 ASCII 字符叫作 Unusual 字符,这类字符在 GIT 输出到终端的时候默认是用 8进制 转义字符输出的(以防乱码)。

但其实现在的终端多数都是支持直接显示非 ASCII 字符的,所以可以关闭掉这个特性。

这个配置项的名字是 core.quotepath,可以通过以下命令来关闭:

$ git config core.quotepath off

若是针对全局(当前登录用户),则加上 --global 参数;若是针对系统,则加上 --system 参数。

示例:

$ git config core.quotepath on # 打开
$ git status
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	"\346\226\260\346\226\207\344\273\266.md"

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

$ git config core.quotepath off # 关闭
$ git status
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	新文件.md

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

参考:

  1. git-config(1),请搜索 core.quotepath
  2. How to make Git properly display UTF-8 encoded pathnames in the console window?

这篇文章的内容已被作者标记为“过时”/“需要更新”/“不具参考意义”。

标签:git