git bash中不能显示中文

在git bash下查看状态中文文件名全部显示为数字,像这样:

pc@pc-PC MINGW64 ~/Desktop/项目笔记 (master)
$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        "1. \346\236\204\345\273\272\347\274\226\350\257\221\347\216\257\345\242\203.doc"
        algorithms.c
        queue.h
        test.cpp
        "\346\226\260\345\273\272 Microsoft Word \346\226\207\346\241\243.doc"
        "\346\265\201\351\200\232\351\200\232\351\201\223\345\256\275\345\272\246\350\256\241\347\256\227.png"
        "\347\256\227\346\263\225.txt"
        "\347\256\227\346\263\225\345\233\276.xls"
        "\347\256\227\346\263\225\345\233\276\344\276\213.png"
        "\347\256\227\346\263\225\347\254\224\350\256\260.doc"

 

把git的配置改一下 git config --global core.quotepath false 就可以了:

pc@pc-PC MINGW64 ~/Desktop/项目笔记 (master)
$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        1. 构建编译环境.doc
        algorithms.c
        queue.h
        test.cpp
        新建 Microsoft Word 文档.doc
        流通通道宽度计算.png
        算法.txt
        算法图.xls
        算法图例.png
        算法笔记.doc

nothing added to commit but untracked files present (use "git add" to track)

pc@pc-PC MINGW64 ~/Desktop/项目笔记 (master)

 

在 git log 时中文依然不能显示,首先试试用 git --no-pager log 能不能显示中文,如果可以,则设置pager为more: git config --global core.pager more 

 


 

以及,其他的一些解决办法:

进入你的项目根目录

1.设置git gui的界面编码

git config --global gui.encoding utf-8

2.设置 commit log 提交时使用 utf-8 编码,可避免服务器上乱码,同时与linux上的提交保持一致!

git config --global i18n.commitencoding utf-8

git config --global i18n.logoutputencoding utf-8

注:

windows系统默认编码为gbk,可改成gbk

如果系统设置了:

export LANG=zh_CN.UTF-8

则日志输出编码设置为utf-8

git config --global i18n.logoutputencoding utf-8

3.在 /etc/profile 中添加:

export LESSCHARSET=utf-8

在试一下问题解决了!



作者:风雷
链接:https://www.zhihu.com/question/57162172/answer/250442443
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

 

posted on 2018-03-27 19:32  枝桠  阅读(13367)  评论(0编辑  收藏  举报

导航