CentOS7源码安装Git环境


获取 git

1
2
3
4
5
6
7
8
# 卸载已安装低版本 git
yum remove git

# 下载 git
wget https://www.kernel.org/pub/software/scm/git/git-2.31.1.tar.gz

# 解压缩
tar xzf git-2.31.1.tar.gz

编译源码

1
2
3
4
5
6
7
8
9
10

# 进入源码目录
cd git-2.31.1

# 安装工具和依赖
yum install libcurl-devel expat-devel openssl-devel

# 编译
make prefix=/opt/git all
make prefix=/opt/git install

应用全局

1
2
3
4
5
# 将git路径加入 bashrc 配置
echo "export PATH=$PATH:/opt/git/bin" >>/etc/bashrc

# 应用bashrc
source /etc/bashrc

验证

1
git --version