1,卸载原有git
yum remove git
2,安装依赖环境
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc -y
yum install gcc perl-ExtUtils-MakeMaker xmlto -y
3,编译安装依赖环境libiconv
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure –prefix=/usr/local/libiconv
make && make install
注意:Win7下安装libiconv时可能出现’gets’ undeclared here (not in a function)错误,解决方法见下面文档:
4,编译安装git
tar zxvf v2.2.1.tar.gz
cd git-2.2.1
make configure
./configure –prefix=/usr/local/git –with-iconv=/usr/local/libiconv
make all doc
make install install-doc install-html
5,设置环境变量
echo “export PATH=$PATH:/usr/local/git/bin” >> /etc/bashrc
source /etc/bashrc
附,libiconv和git下载: