一、查看当前git版本:git --versiongit
查看最新版git:访问https://www.kernel.org/pub/software/scm/git/github
或者https://github.com/git/git/releasescentos
二、官网下载:bash
wget https://Github.com/Git/Git/archive/v2.11.0.tar.gz服务器
(建议本机迅雷下载rz到服务器,安装yum install lrzsz后rz便可)app
解压:tar -zxvf git-2.11.0.tar.gzcurl
三、cd git-2.11.0ui
四、为了防止git安装完后出现url
git clone时候提示fatal: Unable to find remote helper for 'https'.net
提早先安装libcurl-devel
yum install libcurl-devel
五、移除旧版本git:yum remove git
六、make configure
若是报错/bin/sh: autoconf: command not found:
安装libtool便可:yum install autoconf automake libtool
正常会打印:GEN configure
执行
七、./configure --prefix=/usr/local/git --with-iconv =/usr/local/lib(建议优先尝试后者)
或者
./configure --prefix=/usr/local/git --with-iconv --with-curl --with-expat=/usr/local/lib(若是没有安装libiconv请自行安装)
make && make install
①若是报错:cache.h:40:18: fatal error: zlib.h: No such file or directory
安装zlib:yum install zlib、yum install zlib-devel
②若是报错:make[1]: *** [perl.mak] Error 2
make: *** [perl/perl.mak] Error 2
安装:yum install perl-ExtUtils-MakeMaker package
3:报错:make[1]: Leaving directory `/home/app/git-2.5.5/git-gui' 还不知道怎么解决。
八、echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
九、source /etc/bashrc
十、git --version
编译git时报错: zlib.h: No such file or directory
缺乏 zlib的头文件, 开发包没装,
yum install zlib (系统默认已经装上)
yum install zlib-devel
在centos下安装git,make半截出错了,系统是centos 6.3 64位的,报下面的错误:
/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,出来好大一堆,yum search perl-devel,这下好了,执行yum -y install perl-devel,而后继续再make && make install就能够了.