使用 git status 查看有改動但未提交的中文文件名時,發現會顯示爲一串數字,沒有顯示中文的文件名。具體以下所示:git
$ git status
# 位於分支 master
# 還沒有暫存以備提交的變動:
# (使用 "git add <file>..." 更新要提交的內容)
# (使用 "git checkout -- <file>..." 丟棄工做區的改動)
#
# 修改: "\224\257\346\216\247\345\210\266\346\265\201.txt"
複製代碼
解決方案是設置git的 core.quotepath 選項爲false:
git config --global core.quotepath false
api
查看 git config 命令的在線幫助手冊 (git-scm.com/docs/git-co…),裏面對 core.quotepath 選項說明以下:bash
core.quotePath
Commands that output paths (e.g. ls-files, diff), will quote "unusual" characters in the pathname by enclosing the pathname in double-quotes and escaping those characters with backslashes in the same way C escapes control characters (e.g. \t for TAB, \n for LF, \ for backslash) or bytes with values larger than 0x80 (e.g. octal \302\265 for "micro" in UTF-8). If this variable is set to false, bytes higher than 0x80 are not considered "unusual" any more. Double-quotes, backslash and control characters are always escaped regardless of the setting of this variable. A simple space character is not considered "unusual". Many commands can output pathnames completely verbatim using the -z option. The default value is true.less
即,core.quotepath 選項爲true時,會對中文字符進行轉義再顯示,看起來就像是亂碼。
設置該選項爲false,就會正常顯示中文。ide
在一些終端上還要檢查它自身的語言設置,看終端是否能夠正常顯示中文。this