Git for Windows 1.8.3中文设置

这里记录Git for Windows 1.8.3 在Windows XP SP3 上的设置。

这些设置也应适用于Git for Windows 1.7.10及以后的版本,但不适用于1.7.10以前的版本。因为1.7.10及以后的版本的Git repositories才原生支持Unincode。

解决问题的总的思路

能用Unicode的地方都用Unicode。

已知问题
•MSYS bash 不能输入中文(MSYS尚不能完全支持Unicode),但有替代办法(workaround)。

下载Git for Windows 1.8.3

前往 http://git-scm.com/download/win 下载最新版Git for Windows 1.8.3。现时的最新版是Git-1.8.3-preview20130601.exe

安装选项
•在 Select Components 中,选定 Use a TrueType font in all console window (not only for Git Bash)
•在 Adjusting your PATH environment 中,选定 Run Git from the windows Command Prompt\
•其他选项保留缺省值

解决MSYS bash 中ls 中文显示???问题

编辑 etc\git-completion.bash,在最后加入

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


解决git status 乱码

git config --global core.quotepath false


解决gitk显示文件内容中文乱码

在%git%\etc\gitconfig文件末尾添加:
[gui]
	encoding = utf-8
[i18n]
	commitencoding = {utf-8|gbk}


MSYS bash中不能输入中文的替代办法
•不使用MSYS bash,使用windows自带的Command Prompt。经测试,在CMD中输入中文一切正常。
•使用MSYS bash,但在commit 时,使用 git -m,调用vim,在vim中输入中文。经测试,在bash 中的vim中输入中文一切正常。
•使用TortoiseGit。TortoiseGit是Windows 的Git GUI。支持unicode,在测试中尚未发现对中文支持的问题。安装步骤如下: •确保Git for Windows 最新版已安装好
•前往https://code.google.com/p/tortoisegit/wiki/Download?tm=2
•下载并安装TortoiseGit最新版
•下载并安装Chinese, simplified Language Pack


编辑器的选择

至此 Git for Windows 的中文文件名、中文注释等问题均已解决。但文件的内容是GBK还是Unicode是由编辑器决定的。建议使用gvim或UltraEdit32等支持Unicode的编辑器编辑文件,这样可以和Linux和Mac上的项目无缝同步。

参考资料
Git for Windows Unicode Support
Git Status 中文乱码解决
zrong’s Blog??git乱码解决方案汇总
zrong’s Blog 使用Git、Git GUI和TortoiseGit
Working with Git on Windows

猜你喜欢

转载自icbm.iteye.com/blog/1933960