2019独角兽企业重金招聘Python工程师标准>>>
Centos 7.3默认安装的是git 1.8.X 版本
将Centos7.3上的git更新到2.13.1,方法如下:
1.安装编译git时需要的包
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# yum install gcc perl-ExtUtils-MakeMaker
2.删除已有的git
# yum remove git
3.下载git源码
# cd /usr/src
# wget https://www.kernel.org/pub/software/scm/git/git-2.13.1.tar.gz
# tar xzf git-2.13.1.tar.gz
4.编译安装
# cd git-2.13.1
# make prefix=/usr/local/git all
如果执行该命令报以下错误信息:
libgit.a(utf8.o): In function `reencode_string_iconv':
/usr/local/git/utf8.c:463: undefined reference to `libiconv'
libgit.a(utf8.o): In function `reencode_string_len':
/usr/local/git/utf8.c:502: undefined reference to `libiconv_open'
/usr/local/git/utf8.c:521: undefined reference to `libiconv_close'
/usr/local/git/utf8.c:515: undefined reference to `libiconv_open'
collect2: ld returned 1 exit status
make: *** [git-credential-store] Error 1
解决方法如下:
1.安装libiconv
# cd /usr/local
# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
# tar -zxvf libiconv-1.15.tar.gz
# cd libiconv-1.15
# ./configure –-prefix=/usr/local
# make
# make install
2.创建一个软链接到/usr/lib
# ln -s /usr/local/lib/libiconv.so /usr/lib
# ln -s /usr/local/lib/libiconv.so.2 /usr/lib
3.然后回到git目录继续编译
# cd /usr/local/src/git-2.13.1
# make configure
# ./configure --prefix=/usr/local --with-iconv=/usr/local/libiconv
# make
# make install
4.此时,git应该编译安装成功了,测试如下:
# git --version
git version 2.13.1
到此,大功告成.
=============================================
未出错,继续执行以下命令
# make prefix=/usr/local/git install
# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
# source /etc/bashrc
检查一下版本号
# git --version
git version 2.13.1