Windows下Git中正确显示中文的设置方法
具体设置方法如下:
进入目录etc:$ cd /etc
1. 编辑 gitconfig 文件:$ vi gitconfig。在其中增加如下内容:
1
2
3
4
5
6
|
[gui] encoding
= utf-8 #代码库统一使用utf-8 [i18n] commitencoding
= GB2312 #log编码,window下默认gb2312,声明后发到服务器才不会乱码 [svn] pathnameencoding
= GB2312 #支持中文路径 |
2. 编辑 git-completion.bash 文件:$ vi git-completion.bash。在文件最下面添加如下内容:
1
|
alias ls = 'ls
--show-control-chars --color=auto' #ls能够正常显示中文 |
注意等号左右不能有空格。
3. 编辑 inputrc 文件:$ vi inputrc。修改 output-meta 和 convert-meta 属性值:
1
2
|
set output-meta
on #bash中可以正常输入中文 set convert-meta
off |
4. 编辑 profile 文件:$ vi profile。在文件最下面添加如下内容:
1
|
export LESSHARSET=utf-8 |
5. 执行以上三个配置文件,使刚才设置的内容生效:
1
2
3
|
$ source git-completion. bash $ source inputrc $ source profile |
刚过以上五步设置,Git Bash就可以正确显示中文了。