[TOC]
## 下载最新版本源码
[https://mirrors.edge.kernel.org/pub/software/scm/git/](https://mirrors.edge.kernel.org/pub/software/scm/git/)
```
yum install -y wget
wget -O /tmp/git-2.21.0.tar.gz https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.21.0.tar.gz
```
## 解压编译
```
# 安装编译依赖
yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
# 解压
tar -zxf /tmp/git-2.21.0.tar.gz -C /tmp/
cd /tmp/git-2.21.0
# 检验相关依赖,设置安装路径
./configure --prefix=/usr/local/git
# 编译安装
make && make install
```
## 配置全局环境变量
```
# 配置环境变量
vim /etc/profile
# GIT_HOME
GIT_HOME=/usr/local/git
export PATH=$PATH:$GIT_HOME/bin
# 刷新
source /etc/profile
```