centos从源码安装git

源码下载地址

安装步骤

源代码目录下的 INSTALL 文件会有编译安装说明。

安装依赖

1
2
yum -y install curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel autoconf perl-ExtUtils-MakeMaker
yum install -y asciidoc xmlto

编译&安装

1
2
3
4
svn co https://github.com/git/git
autoconf
./configure
make && make install

或者

1
2
3
4
make configure ;# as yourself
./configure --prefix=/usr ;# as yourself
make all doc ;# as yourself
make install install-doc install-html;# as root

查看版本

1
2
git --version
git version 1.7.12.GIT

编译遇到的问题

Can’t locate ExtUtils/MakeMaker.pm

编译 2.9.0 报错

1
2
3
4
5
6
7
    SUBDIR perl
/usr/bin/perl Makefile.PL PREFIX='/usr/local' INSTALL_BASE='' --localedir='/usr/local/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

  • 解决方法

安装 perl-ExtUtils-MakeMaker

1
yum install -y perl-ExtUtils-MakeMaker