windows下GIt Bash中文乱码怎么解决

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了windows下GIt Bash中文乱码怎么解决相关的知识,希望对你有一定的参考价值。

参考技术A windows下git中文乱码解决
进入git安装目录,改一下配置就可以基本解决:
1、etc\gitconfig:
[gui]
encoding
=
utf-8
[i18n]
commitencoding
=
gbk
[svn]
pathnameencoding
=
gbk
说明:打开
Git
环境中的中文支持。pathnameencoding设置了文件路径的中文支持。
2、etc\git-completion.bash:
alias
ls='ls
--show-control-chars
--color=auto'
说明:使得在
Git
Bash
中输入
ls
命令,可以正常显示中文文件名。
3、etc\inputrc:
set
output-meta
on
set
convert-meta
off
说明:使得在
Git
Bash
中可以正常输入中文,比如中文的
commit
log。
4、etc\profile:
export
LESSCHARSET=iso8859
#或者utf-8、gbk
说明:$
git
log
命令不像其它
vcs
一样,n

log
从头滚到底,它会恰当地停在第一页,按
space
键再往后翻页。这是通过将
log
送给
less
处理实现的。以上即是设置
less
的字符编码,使得
$
git
log
可以正常显示中文。其实,它的值不一定要设置为
utf-8,比如
latin1
也可以……。还有个办法是
$
git
–no-pager
log,在选项里禁止分页,则无需设置上面的选项

解决windows下git bash和tig乱码

最近用Windows比较多,说实话我是不喜欢这个系统的。

由于历史遗留问题,Windows中文默认gbk编码,这和Unix/Linux世界以及网络应用的utf8编码有很大的兼容问题。目前Windows似乎考虑迁移到utf8编码,在区域语言设置中加入了默认utf8的beta功能。但是如果你用了这个功能你会发现不但一些破旧不堪的软件会乱码,就连Windows自身都没做好迁移的准备。所以暂时还是使用Windows默认编码吧。

解决git bash和tig乱码:

  • 配置git
git config --global i18n.commitencoding utf-8       # 设置提交日志使用utf-8
git config --global i18n.logoutputencoding utf-8    # 设置输出日志时使用utf-8
  • 在~/.bashrc中添加编码设置
export LC_ALL=zh_CN.utf8
export LANG=zh_CN.utf8
export LESSCHARSET=utf-8  # 设置LESS字符集为utf-8

参考:解决windows git乱码问题

以上是关于windows下GIt Bash中文乱码怎么解决的主要内容,如果未能解决你的问题,请参考以下文章

Windows下Git Bash中VIM打开文件中文乱码

解决windows下git bash和tig乱码

解决windows下git bash和tig乱码

windows下git中文乱码如何解决?

windows下git中sh.exe中文显示乱码问题解决

windows下git中sh.exe中文显示乱码问题解决