在使用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
這個一般是由於伺服器本身自帶的git版本過低造成的:
[root@uatjenkins01 ~]# git --version git version 1.7.1
一般只需要將git版本升級到高版本即可。下面說下git升級的操作記錄:
0)安裝依賴軟體 [root@uatjenkins01 ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc [root@uatjenkins01 ~]# yum install gcc perl-ExtUtils-MakeMaker 1)解除安裝系統自帶的底版本git(1.7.1) [root@uatjenkins01 ~]# git --version git version 1.7.1 [root@uatjenkins01 ~]# yum remove git 2)編譯安裝最新的git版本 [root@uatjenkins01 ~]# cd /usr/local/src/ [root@uatjenkins01 src]# wget https://www.kernel.org/pub/software/scm/git/git-2.15.1.tar.xz [root@uatjenkins01 src]# tar -vxf git-2.15.1.tar.xz [root@uatjenkins01 src]# cd git-2.15.1 [root@uatjenkins01 git-2.15.1]# make prefix=/usr/local/git all [root@uatjenkins01 git-2.15.1]# make prefix=/usr/local/git install [root@uatjenkins01 git-2.15.1]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile [root@uatjenkins01 git-2.15.1]# source /etc/profile [root@uatjenkins01 ~]# git --version git version 2.15.1 ====================================================================== 如果是非root使用者使用git,則需要配置下該使用者下的環境變數 [app@uatjenkins01 ~]$ echo "export PATH=$PATH:/usr/local/git/bin" >> ~/.bashrc [app@uatjenkins01 ~]$ source ~/.bashrc [app@uatjenkins01 ~]$ git --version git version 2.15.1