1、升级原因:
在使用git pull、git push、git clone的时候,或者在使用jenkins发版的时候,可能会报类似如下的错误:
error: The requested URL returned error: 401 Unauthorized while accessing https://git.oschina.net/zemo/demo.git/info/refs
fatal: HTTP request failed
像centos7.5一般自带的git都是1.8.3.1版本的,比较老了,所以有时候需要升级一下git版本
2、测试环境说明:
Last login: Mon Jan 18 17:02:47 2021 from 192.168.98.72
[root@host-10-121-3-211 ~]# git version
git version 1.8.3.1
[root@host-10-121-3-211 ~]#
3、安装依赖软件:
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc gcc perl-ExtUtils-MakeMaker
4、卸载系统自带的低版本:
yum remove git
5、编译安装最新的git版本:
[root@host-10-121-3-211 ~]# cd /usr/local/src/
[root@host-10-121-3-211 src]# wget https://www.kernel.org/pub/software/scm/git/git-2.30.0.tar.xz
wget: /home/Anaconda3/lib/libuuid.so.1: no version information available (required by wget)
--2021-01-19 14:28:33-- https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.30.0.tar.xz
正在解析主机 mirrors.edge.kernel.org (mirrors.edge.kernel.org)... 147.75.95.133, 2604:1380:3000:1500::1
正在连接 mirrors.edge.kernel.org (mirrors.edge.kernel.org)|147.75.95.133|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:4894768 (4.7M) [application/x-xz]
正在保存至: “git-2.30.0.tar.xz.1”
100%[=================================================>] 4,894,768 10.3KB/s 用时 9m 52s
2021-01-19 14:38:30 (8.07 KB/s) - 已保存 “git-2.30.0.tar.xz.1” [4894768/4894768])
(base) [root@host-10-121-3-211 src]# tar -vxf git-2.30.0.tar.xz
git-2.30.0/
git-2.30.0/.clang-format
git-2.30.0/.gitattributes
git-2.30.0/.github/
git-2.30.0/.github/CONTRIBUTING.md
git-2.30.0/.github/PULL_REQUEST_TEMPLATE.md
git-2.30.0/.gitignore
git-2.30.0/.gitmodules
git-2.30.0/.mailmap
...
# 然后再运行下面的命令:
[root@host-10-121-3-211 src]# cd git-2.30.0
[root@host-10-121-3-211 src]# make prefix=/usr/local/git all
[root@host-10-121-3-211 src]# make prefix=/usr/local/git install
[root@host-10-121-3-211 src]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile
[root@host-10-121-3-211 src]# source /etc/profile
6、安装完成🌵
[root@host-10-121-3-211 git-2.30.0]# git --version
git version 2.30.0
[root@host-10-121-3-211 git-2.30.0]#