時間:2020年8月17日15:09:12
問題:Git log亂碼問題
[email protected] MINGW64 /d/p2p_web (master)
$ git config --global core.quotepath false
[email protected] MINGW64 /d/p2p_web (master)
$ git config --global gui.encoding utf-8
[email protected] MINGW64 /d/p2p_web (master)
$ git config --global i18n.commit.encoding utf-8
[email protected] MINGW64 /d/p2p_web (master)
$ git config --global i18n.logoutputencoding utf-8
[email protected] MINGW64 /d/p2p_web (master)
$ export LESSCHARSET=utf-8

解決辦法如下:
在Linux及托管網站上預設的編碼都是utf-8,而Windows系統預設編碼不是采用utf-8,是以Git 用戶端在Windows下總是會有一些問題。一個解決方案就是通過設定git編碼為utf-8。
設定 Git 支援 utf-8 編碼
在指令行下輸入以下指令:
依次執行以下指令:
以上指令等效于:
在 etc\gitconfig 中添加如下内容:
說明:
- gui.encoding = utf-8 解決在 $ git gui 和 gitk 裡中文亂碼。如果發現代碼中的注釋顯示亂碼,可以設定項目根目錄中.git/config檔案添加
- i18n.commitencoding = utf-8 設定 commit log 送出時使用 utf-8 編碼,可避免伺服器上亂碼,同時與Unix上的送出保持一緻!
- i18n.logoutputencoding = gbk 使得在 $ git log 時編碼設定為 utf-8
- export LESSCHARSET=utf-8使得 $ git log 可以正常顯示中文(配合i18n.logoutputencoding 的設定)
讓 ls 指令可以顯示中文名稱
修改 etc\git-completion.bash 檔案:
這樣設定後,基本可以解決中文顯示的問題。
檢視顯示正常了:
如下
從此不在為亂碼頭疼: