Created
April 8, 2014 16:33
-
-
Save Liner-z/10152646 to your computer and use it in GitHub Desktop.
windows下git bash显示中文
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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默认为其它编辑器: | |
$ git config --global core.editor "notepad" | |
其中 notepad 可以替换为更好用的 wordpad、notepad++ 等(不过它们在命令行里无法直接访问,得先设置 PATH 变量)。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment