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
來源:知乎
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM