centos7.2下编译安装git

时间:2022-08-10 19:50:58

centos最新的7.2版本,git居然是1.8,而最新的git版本是2.9

差的太多了,何况git2.0后有大更新。于是,我决定编译安装。中间有一点小破折,记录一下,备忘。

1,下载最新的源码,网址:https://www.kernel.org/pub/software/scm/git/

我下载的地址:https://www.kernel.org/pub/software/scm/git/git-2.9.2.tar.gz

2,解压:tar   xzvf   git-2.9.2.tar.gz

3,进入解压后的git目录后,执行:./configure很顺利。

4,make的时候出错了。提示如下:

In file included from credential-store.c:1:
cache.h:21:18: warning: zlib.h: No such file or directory
In file included from credential-store.c:1:
cache.h:23: error: expected specifier-qualifier-list before ‘z_stream’

make: *** [credential-store.o] Error 1

=============

缺少 zlib的头文件, 开发包没装,

yum install zlib (系统默认已经装上)

yum install zlib-devel

5,make install时,有出现一个错误。提示如下:

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.
=========================

原来一个perl的模块需要安装:perl-ExtUtils-Embed

yum install perl-ExtUtils-Embed -y

6,经过以上的波折,终于make install成功。但是运行git的时,又提示:
/usr/bin/git 没有哪个文件或目录
=================================
原来git安装到/usr/local/bin/目录内了,而centos默认该目录没有在搜索目录内。
解决办法,建立一个软链接吧。

ln -s /usr/local/bin/git   /usr/bin/git

大功告成。