Centos7.3 安装升级 git(亲测有效)

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

 

转载于:https://my.oschina.net/crisslin/blog/850586

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值