windows下git乱码解决方案
为了搞定git乱码问题,几乎把网上所有git乱码文章看了一遍,总算让我解决了。
我用的git和TortoiseGit版本:
msysgit: V1.7.9
http://msysgit.googlecode.com/files/Git-1.7.9-preview20120201.exe
Tortoisegit: V1.7.7.0
http://tortoisegit.googlecode.com/files/TortoiseGit-1.7.7.0-32bit.msi
发现不同的版本解决方法还不一样,之前试了一个最新版本,发现按网上的方法怎么弄都不行。后来下了这个旧的版本,一切OK。
下面是我的配置文件
C:\Documents and Settings\Administrator\.gitconfig
[http]
sslverify = false
[user]
name = xxx
email = xxx@xxx.com
[alias]
ci = commit -a -s
co = checkout
st = status -a
praise = blame
am3 = am --signoff --3way --ignore-space-change --keep-cr
[i18n]
logoutputencoding = gbk
commitencoding = utf-8
[core]
editor = emacs
quotepath = false
autocrlf = false
[gui]
encoding = utf-8
[diff]
external = E:/git-diff-wrapper.sh
[svn]
pathnameencoding = gbk
顺便说下,我用的diff是WinMerge,之前用的bc列入黑名单了,不想折腾了,直接用开源的。
E:/git-diff-wrapper.sh
#!/bin/sh
# diff is called by git with 7 parameters:
# path old-file old-hex old-mode new-file new-hex new-mode
#"C:/Program Files/Beyond Compare 3/BCompare.exe" "$2" "$5" | cat
"C:/Program Files/WinMerge/WinMergeU.exe" -e -ub "$2" "$5" | cat
C:\Program Files\Git\etc\git-completion.bash
添加一行
alias ls='ls --show-control-chars --color=auto'
C:\Program Files\Git\etc\gitconfig
[core]
symlinks = false
autocrlf = false
[color]
diff = auto
status = auto
branch = auto
interactive = true
[pack]
packSizeLimit = 2g
[help]
format = html
[http]
sslCAinfo = /bin/curl-ca-bundle.crt
[sendemail]
smtpserver = /bin/msmtp.exe
[diff "astextplain"]
textconv = astextplain
[rebase]
autosquash = true
C:\Program Files\Git\etc\inputrc
set meta-flag on
set input-meta on
set output-meta on
set convert-meta off
C:\Program Files\Git\etc\profile
添加一行
export LESSCHARSET=utf-8
我用的editor是windows下的emacs.很好用。但是也存在乱码问题,在git bash中commit时,如果输入comment的是中文,可能会显示不能转换为utf-8,这可能和编辑器打开COMMIT_EDITMSG默认编码有关,并且当COMMIT_EDITMSG中有中文文件名时,emacs的编码总是c(U),也就是 chinese-gbk-unix。这会导致提交的comment在别处是乱码。我想了个笨方法,在emacs配置文件中每次加载文件时,设置使用utf-8编码:
C:\Documents and Settings\Administrator\.emacs
(defun set_encode_my () (set-buffer-file-coding-system 'utf-8) ) (add-hook 'find-file-hook 'set_encode_my)
posted on 2012-05-03 20:20 jianglili 阅读(1366) 评论(0) 编辑 收藏 举报