CentOS下安装Git

CentOS中yum里没有Git,需要手动安装。

首先需要安装git的依赖包

> yum install curl
> yum install curl-devel
> yum install zlib-devel
> yum install openssl-devel
> yum install perl
> yum install cpio
> yum install expat-devel
> yum install gettext-devel

下载最新的git包

> wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
> tar xzvf git-latest.tar.gz
> cd git-xxxx-xx-xx
> autoconf
> ./configure
> make | make install

验证是否安装成功:检查安装的版本

> git --version

———————————— 12-18日更新 ——————————

经朋友提示,在检查完以上依赖包后,还有可能出现一种错误,如下所示:

/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/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/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的问题,使用yum search perl-devel查出一些包。

> yum install perl-devel.i686

继续make | make install。 成功!