Git的使用——解决中文乱码

来源:互联网 发布:js时间选择器 编辑:程序博客网 时间:2024/06/04 18:55

原贴:http://blog.csdn.net/tianzhaoai/article/details/46618535


Git Bush安装之后,如果什么都不设置的话,windows下ls回车之后一般情况下中文都会乱码的。在这就先解决一下这个问题

打开git Bash

 进入目录:$ cd /etc

 1. 编辑 gitconfig 文件:$ vi gitconfig

      文件中增加内容

[cpp] view plain copy
  1. [gui]    
  2. encoding = utf-8 #代码库统一使用utf-8    
  3. [i18n]    
  4. commitencoding = GB2312 #log编码,window下默认gb2312,声明后发到服务器才不会乱码    
  5. [svn]    
  6. pathnameencoding = GB2312 #支持中文路径    

2. 编辑 git-completion.bash 文件:$ vi git-completion.bash

    最下面添加

[cpp] view plain copy
  1. alias ls='ls --show-control-chars --color=auto' #ls能够正常显示中文   

3. 编辑 inputrc 文件:$ vi inputrc

    修改 output-meta 和 convert-meta 属性值

[cpp] view plain copy
  1. set output-meta on #bash中可以正常输入中文    
  2. set convert-meta off    

4. 编辑 profile 文件:$ vi profile

    最下面添加

[cpp] view plain copy
  1. export LESSHARSET=utf-8    

5. 重新编译配置文件,使文件生效

[cpp] view plain copy
  1. $ source git-completion.bash  
  2. $ source inputrc  
  3. $ source profile  
   OK,这样就好了。
原创粉丝点击