Windows下Git Bash中文乱码

来源:互联网 发布:zbrush for mac中文 编辑:程序博客网 时间:2024/06/09 01:08

文章转自:https://gist.github.com/nightire/5069597

原因

中文乱码的根源在于 windows 基于一些历史原因无法全面支持 utf-8 编码格式,并且也无法通过有效手段令其全面支持。

解决方案

  1. 安装

  2. 设置(以下需要修改的文件,均位于 git 安装目录下的 etc/ 目录中)

2.1. 让 Git 支持 utf-8 编码

在命令行下输入以下命令:

$ git config --global core.quotepath false  # 显示 status 编码$ git config --global gui.encoding utf-8# 图形界面编码$ git config --global i18n.commit.encoding utf-8# 提交信息编码$ git config --global i18n.logoutputencoding utf-8# 输出 log 编码$ export LESSCHARSET=utf-8# 最后一条命令是因为 git log 默认使用 less 分页,所以需要 bash 对 less 命令进行 utf-8 编码

2.2. 让 ls 命令可以显示中文名称

修改 git-completion.bash 文件:

# 在文件末尾处添加一行alias ls="ls --show-control-chars --color"


0 0
原创粉丝点击