Centos下升級git版本
阿新 • • 發佈:2021-01-20
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
(base) [[email protected] ~]# git version
git version 1.8.3.1
(base) [[email protected] ~]#
3、安裝依賴軟體:
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc
# yum install gcc perl-ExtUtils-MakeMaker
4、解除安裝系統自帶的低版本:
yum remove git
5、編譯安裝最新的git版本
[[email protected] ~]# cd /usr/local/src/
[[email protected] src]# wget https://www.kernel.org/pub/software/scm/git/git-2.15.1.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.15.1.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.15.1.tar.xz.1”
100%[=================================================>] 4,894,768 10.3KB/s 用時 9m 52s
2021-01-19 14:38:30 (8.07 KB/s) - 已儲存 “git-2.15.1.tar.xz.1” [4894768/4894768])
(base) [[email protected] src]# tar -vxf git-2.15.1.tar.xz
git-2.15.1/
git-2.15.1/.clang-format
git-2.15.1/.gitattributes
git-2.15.1/.github/
git-2.15.1/.github/CONTRIBUTING.md
git-2.15.1/.github/PULL_REQUEST_TEMPLATE.md
git-2.15.1/.gitignore
git-2.15.1/.gitmodules
git-2.15.1/.mailmap
...
# 然後再執行下面的命令:
[[email protected] src]# cd git-2.15.1
[[email protected] src]# make prefix=/usr/local/git all
[[email protected] src]# make prefix=/usr/local/git install
[[email protected] src]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile
[[email protected] src]# source /etc/profile
[[email protected] src]# git --version
6、安裝完成
(base) [[email protected] git-2.15.1]# git --version
git version 2.15.1
(base) [[email protected] git-2.15.1]#