一、下载安装包

https://github.com/git/git/releases,目前最新版2.15

wget https://github.com/git/git/archive/v2.15.0.tar.gz

网速慢的话可以搞个代理,或者用迅雷下载。

二、安装依赖库

sudo yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel 
sudo yum install -y gcc-c++ perl-ExtUtils-MakeMaker

三、解压和安装

安装目录/usr/local/git-2.15.1

#解压
tar -zxvf v2.15.0.tar.gz
cd git-2.15.1/
# 安装
make configure 
./configure --prefix=/usr/local/git-2.15.1
make && sudo make install

五、添加环境变量

# 删除原来的git
sudo yum remove git
# 添加软链接
sudo ln -s /usr/local/git-2.15.1 /usr/local/git
sudo ln -s /usr/local/git/bin/git /usr/bin/git
# 添加到环境变量
sudo sh -c ''echo "export GIT_HOME=/usr/local/git" >> /etc/profile''
sudo sh -c ''echo "export PATH=\$PATH:\$GIT_HOME/bin" >> /etc/profile''
source /etc/profile

六、检查是否安装成功

git --version
# git version 2.15.1
最后修改:2017 年 08 月 19 日
如果觉得我的文章对你有用,请随意赞赏