windows下git乱码解决方案

摘要:
为了解决胡言乱语的问题,我在网上阅读了几乎所有的胡言乱语文章,最后让我来解决它。Gitconfig[http]sslverify=false[user]name=xxxxemail=xxx@xxx.com[别名]ci=commit-a-sco=checkouts=status apraise=blazeam3=am--signoff--3way--忽略空间更改--保持cr[i18n]logoutputencoding=gbkcommittencoding=utf-8[core]editor=emacsquoth=false autocrlf=false[gui]encoding=utf-8[diff]external=E:/git-diff-wrapper.sh[svn]pathnameencoding=gbk顺便说一句,我使用diff is WinMerge。之前使用的bc被列入黑名单。我不想辗转反侧。我直接使用开源/Bin/sh#difficscaledbygitwith7个参数:#pathold fileold hexald modenew filenew hexaew mode#“C:\ProgramFiles\BeyondCompare3/BCompare.exe”“$2”“$5”|cat“C:\ProgramFiles\WinMerge/WinMergeU.exe”-eub“$2“”$5“|catC:ProgramFiles Git etc Git-completion.bash添加一行别名s='ls--show control char-color=auto'C:Program Files Git等gitconfig[core]symlinks=false autocrlf=false[color]diff=autostatus=autobranch=autointeractive=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:程序文件Git等inputrcsetmeta flagstinput metaonsetoutput metaonsetconvert metaffC:程序文件Git等profile添加一行exportLESCHARSET=utf-8我的编辑器是Windows下的emacs。它非常有用。这将导致提交的评论在其他地方被混淆。

为了搞定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)

免责声明:文章转载自《windows下git乱码解决方案》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Go并发【原创】hadoop启动错误 找不到路由 解决方法下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

git使用命令

新建分支 git branch 分支名 切换分支 git checkout 分支名 进行项目上传 git add . git commit -m "提交的信息" git remote add origin 远程仓库地址 git push -u origin 分支名 git add 参数的区别 git add -u:将文件的修改、文件的删除,添加到暂存...

idea配置git,github , gitee

先在本地安装git,再在idea里面配置 1》file --->settings ----->Version  Control  点击test,可以看到git相关的信息: 2》配置github,github的地址,github的注册的用户名和密码,点击test即可测试是否可以连接 3》配置gitee,gitee的地址,创建token,配置...

用git如何把单个文件回退到某一版本

暂定此文件为a.jsp 1.首先到a.jsp所在目录: 通过 git  log a.jsp 查看a.jsp的更改记录 2.找到想要回退的版本号:例如 fcd2093 通过 git reset  fcd2093 a.jsp 把文件回退 3.提交本次回退 git commit -m "注释内容" 4.选中该文件 git checkout a.jsp...

Git 版本导致 clone 故障

问题描述: git clone 报错如下: Initialized empty Git repository in /root/project_php/.git/ error: The requested URL returned error: 401 Unauthorized while accessing http://tone.verru.cn:8...

记录一次idea的git导致的macpro风扇狂转问题

现象 macpro风扇忽然狂转不停;使用软件Macs Fan Control检测如下:cpu温度持续过高(超过50度),风扇当前转速比较高 解决 观察cpu使用情况,发现git占用cpu很高,而且持续。删除git进程,风扇恢复正常。 查看git进程的详细信息,发现父进程是idea 打开idea的版本控制,发现处于Unversioned Files状态的文件...

eclipse中git更新操作

1,本地已经修改的代码不要commit和push 2,选中工程,右击Team,然后点击Fetch from Upstream,从远程服务器拉取最新的代码 3,上一步操作完成,再右击工程,选中Team,然后点击Synchronize Workspace,确认跟远程服务器代码是否一致,如果冲突就解决冲突,如果没有冲突就进入下一步。图标样式如图,才算解决冲突。...