系統centos7,默認安裝的git版本是1.8,在使用code server、jenkins等軟件時,偶爾提示失敗。原因是git版本太低。接下來,我們升級git。
1、卸載:
git --version
git version 1.8.3
yum remove git
2、下載:
https://git-scm.com/ download界面選擇操作系統類型,下載。在linux上,基本提供的是源碼編譯安裝。
cd /usr/local/src
wget https://www.kernel.org/pub/software/scm/git/git-2.27.0.tar.gz
tar -xvzf git-2.27.0.tar.gz
cd git-2.27.0
3、安裝:
pwd
/usr/local/src/git-2.27.0
make prefix=/usr/local/git all
這一步可能會報如下錯誤:
http.h:6:23: fatal error: curl/curl.h: No such file or directory
#include <curl/curl.h>
解決方法:
yum install curl-devel -y
接下來:
make prefix=/usr/local/git install
沒有問題後,配置環境變量:
$ echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile
$ source /etc/profile
$ git --version
git version 2.27.0