1、安装依赖的包:
yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
2、下载git源码并解压:
wget https://github.com/git/git/archive/v2.3.0.zip
unzip v2.3.0.zip
cd git-2.3.0
3、编译安装:
make prefix=/usr/local/git all
make prefix=/usr/local/git install
ps1: 如果报错“……has modification time……”—— 使用ntpdate自动校正系统时间。
ps2: 如果报错报错“Writing perl.mak for Git make[2]: * [perl.mak] Error 1”——重启apache服务,service httpd restart.
4、添加到环境变量:
vim/etc/profile∗在文件的最后一行,添加:exportPATH=/usr/local/git/bin: PATH
5、使用source命令立即生效:
source /etc/profile
6、验证安装成功:
git - -version