git status中文文件名显示问题

在linux或者maxos上用git status查看项目状态时,发现中文文件名显示有问题,如下:

modified: "public/346230216344273243347216213345256210/347216213345256210350241214344271246345274240346241202345262251345242223345277227351223255/info.json"

上面中文文字被显示成xxxxxxxxx,是因为git对0x80以上的字符进行quote造成的,man git-config官方文档说明如下。

The commands that output paths (e.g. ls-files, diff), when not given the -z option, will quote "unusual" characters in the pathname by enclosing the pathname in a double-quote pair and with backslashes the same way strings in C source code are quoted. If this variable is set to false, the bytes higher than 0x80 are not quoted but output as verbatim. Note that double quote, backslash and control characters are always quoted without -z regardless of the setting of this variable.


git config core.quotepath false


默认会启用shell的环境变量$EDITOR所指定的软件,一般都是vimemacs,也有些是nano。当然也可以使用git config --global core.editor命令设定你喜欢的编辑软件。

git config --global core.editor "vim"
export GIT_EDITOR=vim

使用Sublime Text则用以下命令:

git config --global core.editor "subl -n -w"


git config --global core.editor "mate -w"


  1. Associating text editors with Git
  2. git-config Manual Page