在linux或者maxos上用git status查看项目状态时,发现中文文件名显示有问题,如下:
modified: "public/\346\230\216\344\273\243\347\216\213\345\256\210/\347\216\213\345\256\210\350\241\214\344\271\246\345\274\240\346\241\202\345\262\251\345\242\223\345\277\227\351\223\255/info.json" |
上面中文文字被显示成\xxx\xxx\xxx,是因为git对0x80以上的字符进行quote造成的,man git-config官方文档说明如下。
core.quotePathThe 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 |
设置git编辑器
默认会启用shell的环境变量$EDITOR所指定的软件,一般都是vim或emacs,也有些是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" |
使用TextMate则用以下命令:
git config --global core.editor "mate -w" |