我这里是直接以ROOT方式登录的。如果当前账户不是root账户,请在命令前面加上sudo
1.安装Git所需依赖
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# yum install gcc perl-ExtUtils-MakeMaker
2.下载并安装Git2.10.2
# cd ~
# wget https://github.com/git/git/archive/v2.10.2.tar.gz
# tar -zxvf git-2.10.2.tar.gz
3.编译并安装Git
# cd git-2.10.2
# make prefix=/usr/local/git all
# make prefix=/usr/local/git install
4.将Git加入系统环境变量
# vi /etc/bashrc
将下面代码加入文件最后一行:
export PATH=$PATH:/usr/local/git/bin
保存并source一下
#source /etc/bashrc
5.检查是否安装成功
# git --version
git version 2.10.2
这样Git最新版就安装成功!