在使用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版本过低造成的:
[[email protected] ~]# git --version git version 1.7.1
一般只需要将git版本升级到高版本即可。下面说下git升级的操作记录:
1)卸载系统自带的底版本git(1.7.1) [[email protected] ~]# git --version git version 1.7.1 [[email protected] ~]# yum remove git 2)编译安装最新的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 [[email protected] src]# tar -vxf git-2.15.1.tar.xz [[email protected] src]# cd git-2.15.1 [[email protected] git-2.15.1]# make prefix=/usr/local/git all [[email protected] git-2.15.1]# make prefix=/usr/local/git install [[email protected] git-2.15.1]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile [[email protected] git-2.15.1]# source /etc/profile [[email protected] ~]# git --version git version 2.15.1 ====================================================================== 如果是非root用户使用git,则需要配置下该用户下的环境变量 [[email protected] ~]$ echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc [[email protected] ~]$ source /etc/bashrc [[email protected] ~]$ git --version git version 2.15.1