参考文献:https://www.cnblogs.com/albertrui/p/7866644.html
问题:
使用git pull、git push、git clone会报类似如下的错误,
error: The requested URL returned error: 401 Unauthorized while accessing https://git.oschina.net/zemo/demo.git/info/refs
fatal: HTTP request failed
原因分析:
一般是由于git版本的问题,可以使用如下指令查看版本,
# git --version
git version 1.7.0.1
可以通过安装更高的版本解决问题。
centOS下安装最新版本git
1.安装依赖库
$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
$ yum install gcc perl-ExtUtils-MakeMaker
2.卸载旧版git
加入原先有用yum安装过git,则需要先卸载一下
$ yum remove git
3.下载源码
$ cd /usr/src
$ wget -O git.zip https://github.com/git/git/archive/master.zip
$ unzip git.zip
$ cd git-master/
这里直接从master分支下载,所以能直接下载最新的,如果要指定版本则需要到其版本库中找对应的tag了。
4.编译和安装
$ make prefix=/usr/local/git all
$ make prefix=/usr/local/git install
5.将git目录加入PATH
$ echo 'export PATH=$PATH:/usr/local/git/bin' >> /etc/bashrc
$ or
$ echo 'export PATH=$PATH:/usr/local/git/bin' > /etc/profile.d/git.sh
$
$ source /etc/bashrc
安装成功后就可以查看到git版本了。
$ git --version
git version 2.9.0.GIT