centos7安装最新版git

centos7安装最新版git

自带的版本

1
2
[root@0ef053b03825 ~]# git --version
git version 1.8.3.1

太旧了,有时候会有一些小问题

目前最新版是 edge-git-2.9.5 或者 git-scm2.38.0 (2022-10-04)

1
2
3
https://mirrors.edge.kernel.org/pub/software/scm/git/
或者
https://github.com/git/git/releases/tag/v2.38.0

我这里用 mirrors.edge.kernel.org的2.9.5版本 因为2.38有一个依赖还在测试版的c99的问题处理起来麻烦

1
2
#安装编译和运行新版git的依赖
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc gcc perl-ExtUtils-MakeMaker

yum remove git #卸载自带的git cd /usr/local/src/ wget -c https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz tar -zxvf git-* cd git-* make prefix=/opt/git all make prefix=/opt/git install echo “export PATH=$PATH:/opt/git/bin” » /etc/profile #如果还有其他自定义path,最好是自己修改一下 /etc/profile source /etc/profile #更新 git –version #查看是否生效

comments powered by Disqus