原創 Git bash不能輸入中文

2022-04-04 20:53:44 字數 1579 閱讀 6357

一.點選左上角git圖示

,選擇預設值

二.彈出屬性面板,選擇"選項"標籤頁,預設**頁選擇「936 簡體中文」

三.關閉git,重新開啟,選擇字型標籤頁。

四.字型選擇「新宋體」即可!

發現新的問題,補充一些:

1、c:\program files\git\etc\git-completion.bash:

alias ls='ls --show-control-chars --color=auto'

說明:使得在 git bash 中輸入 ls 命令,可以正常顯示中文檔名。

2、c:\program files\git\etc\inputrc:

set output-meta on

set convert-meta off

說明:使得在 git bash 中可以正常輸入中文,比如中文的 commit log。

3、c:\program files\git\etc\profile:

export lesscharset=utf-8

說明:$ git log 命令不像其它 vcs 一樣,n 條 log 從頭滾到底,它會恰當地停在第一頁,按 space 鍵再往後翻頁。這是通過將 log 送給 less 處理實現的。以上即是設定 less 的字元編碼,使得 $ git log 可以正常顯示中文。其實,它的值不一定要設定為 utf-8,比如 latin1 也可以……。還有個辦法是 $ git –no-pager log,在選項裡禁止分頁,則無需設定上面的選項。

4、c:\program files\git\etc\gitconfig:

[gui]

encoding = utf-8

說明:我們的**庫是統一用的 utf-8,這樣設定可以在 git gui 中正常顯示**中的中文。

[i18n]

commitencoding = gb2312

說明:如果沒有這一條,雖然我們在本地用 $ git log 看自己的中文修訂沒問題,但,一、我們的 log 推到伺服器後會變成亂碼;二、別人在 linux 下推的中文 log 我們 pull 過來之後看起來也是亂碼。這是因為,我們的 commit log 會被先存放在專案的 .git/commit_editmsg 檔案中;在中文 windows 裡,新建檔案用的是 gb2312 的編碼;但是 git 不知道,當成預設的 utf-8 的送出去了,所以就亂碼了。有了這條之後,git 會先將其轉換成 utf-8,再發出去,於是就沒問題了。

$ git config --global core.editor "notepad"

其中 notepad 可以替換為更好用的 wordpad、notepad++ 等(不過它們在命令列裡無法直接訪問,得先設定 path 變數)。

Git Bash中文亂碼

開啟git bash 進入目錄 cd etc 1.編輯 gitconfig 檔案 vigitconfig 檔案中增加內容 gui encoding utf 8 庫統一使用utf 8 i18n commitencoding gb2312 log編碼,window下預設gb2312,宣告後發到伺服器才不...

gitbash解決中文亂碼

進入git安裝目錄,開啟etc目錄 1 編輯gitconfig檔案,檔案中增加內容 1 2 3 4 5 6 gui encoding utf 8 庫統一使用utf 8 i18n commitencoding gb2312 log編碼,window下預設gb2312,宣告後發到伺服器才不會亂碼 svn...

Git bash 中支援中文

git bash 中支援中文 1.git bash中 ls 命令顯示中文 在c program files x86 git etc git completion.bash檔案的末尾新增 說明 使得在 git bash 中輸入 ls 命令,可以正常顯示中文檔名。2.git bash 正常輸入中文 在c...