1.首先先卸载掉之前的旧版本
#yum remove -y git***
2.下载2.2.1的版本的git
#wget https://github.com/git/git/archive/v2.2.1.tar.gz
3.解压文件
#tar -zxvf v2.2.1.tar.gz
4.配置到环境
# cd git-2.2.1
# make configure
# ./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv
5.安装
# make all doc
# make install install-doc install-html
# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
# source /etc/bashrc
6.查看是否安装完成
#git --version
git version 2.2.1
注意:
有部分人在执行make all doc的时候会报错,
报错内容如下:
usr/bin/perl Makefile.PL PREFIX=’/usr/local/git’ INSTALL_BASE=” –localedir=’/usr/local/git/share/locale’
Can’t locate ExtUtils/MakeMaker.pm in @INC (@INC contains:
/usr/local/lib64/perl5 /usr/local/share/perl5
/usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl
/usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.
BEGIN Failed–compilation aborted at Makefile.PL line 3.
make[1]: * [perl.mak] Error 2
make: * [perl/perl.mak] Error 2
这时,需要安装一下
#yum install perl-ExtUtils-MakeMaker -y
#yum install curlcurl-develzlib-developenssl-develperlcpioexpat-develgettext-devel -y