CentOS 安装 git2.x.x 版本

方法一 源码方式安装

第一步:卸载旧的git版本、

$ yum remove git 

第二步:下载git

$ wget --no-check-certificate https://www.kernel.org/pub/software/scm/git/git-2.8.4.tar.gz
# 或者使用 curl -O -k  https://www.kernel.org/pub/software/scm/git/git-2.8.4.tar.gz 进行下载

第三步:解压

$ tar -zxvf git-2.8.4.tar.gz

第四步:安装依赖包

$ yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel
$ yum install -y gcc perl-ExtUtils-MakeMaker
# 升级 解决  SSL connect error
$ yum update -y nss curl libcurl

第五步:编译安装

# 切换到git目录
$ cd git-2.8.4
# 创建要安装的目录
$ mkdir -p  /usr/local/git
# 编译安装
make prefix=/usr/local/git all
make prefix=/usr/local/git install

第六步:添加环境变量

# 添加环境变量
$ vim /etc/profile
# 添加以下配置
$ export PATH=$PATH:/usr/local/git/bin

第七步:使配置生效

# 使新加的环境变量生效
$ source /etc/profile
# 验证是否配置成功
$ git --version

TIPS
升级了git版本后git clone报ssl错误的解决方法
由于升级了git版本,git clone 的时候报了如下的错误
fatal: unable to access 'https://github.com/open-falcon/falcon-plus.git/': SSL connect error
解决方法 yum update -y nss curl libcurl

方法二 第三方仓库安装

关于IUS
IUS第三方仓库不仅仅用于 git 的安装,它是包含了很多软件工具,它的使用指南里说明了一切
redis40u、redis32u、mysql56u、python36u、

# Git第三方仓库安装方式(IUS)
# 安装使用里面说的自动化安装脚本
$ curl https://setup.ius.io | sh
# 可以看到 git2u相关内容
$ yum search git 
# ...
# git.x86_64 : Fast Version Control System
# git2u.x86_64 : Fast Version Control System
# gitflow.noarch : Extensions providing operations for V. Driessen's branching model
# 执行安装,并查看下版本
$ yum remove -y git | yum -y install git2u
$ git --version
原文地址:https://www.cnblogs.com/itgiser/p/11345636.html