Git status中文乱码问题

问题描述

在执行git sstatus时中文文件名无法正常显示,其实也不是乱码,而是显示成中文对应的Unicode编码了,如下:

1
2
3
4
5
6
7
8
9
10
root@huzhifeng:~/blog# 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)

"source/_posts/WiFi\345\256\232\346\227\266\345\274\200\345\205\263.md"

nothing added to commit but untracked files present (use "git add" to track)
root@huzhifeng:~/blog#

解决方案

只需要配置git config --global core.quotepath false

1
root@huzhifeng:~/blog# git config --global core.quotepath false

Git配置文件如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
root@huzhifeng:~/blog# cat ~/.gitconfig
[user]
name = huzhifeng
email = zhifeng.hu@email.com
[core]
editor = vim
quotepath = false
[alias]
co = checkout
st = status
dt = difftool
di = diff
root@huzhifeng:~/blog#

现在执行命令git status能够正常显示中文了,如下:

1
2
3
4
5
6
7
8
9
10
root@huzhifeng:~/blog# 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)

source/_posts/WiFi定时开关.md

nothing added to commit but untracked files present (use "git add" to track)
root@huzhifeng:~/blog#

参考

Git 中文乱码解决方案

EOF