centos7安装更新git
CentOS7上的Git版本太陈旧,在使用过程中会遇到问题,因此需要升级git (opens new window)版本。
# git --version
git version 1.8.3.1
# 系统版本:(CentOS 7.6)
# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
1
2
3
4
5
2
3
4
5
# 安装依赖包
源代码安装和编译git,需安装一些依赖。
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc -y
yum install gcc perl-ExtUtils-MakeMaker -y
1
2
2
# 卸载旧版本
yum remove git
1
# 安装步骤
cd /usr/local/src/
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.38.1.tar.gz
tar -xvf git-2.38.1.tar.gz
cd git-2.38.1/
./configure --prefix=/usr/local/git all
make -j && make install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# 验证版本
[root@localhost ~]# git --version
git version 2.38.1
1
2
2
上次更新: 2023/04/21, 08:57:47