错误信息
error: The requested URL returned error: 401 Unauthorized while accessing https://git.oschina.net/zemo/demo.git/info/refs
fatal: HTTP request failed
解决方案
1、安装依赖
[root@localhost ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc
[root@localhost ~]# yum install gcc perl-ExtUtils-MakeMaker
2、卸载系统自带的底版本git(1.7.1)
[root@localhost ~]# git --version
git version 1.7.1
[root@localhost ~]# yum remove git
3、编译安装最新的git版本
[root@localhost ~]# cd /soft/ 进入下载文件的目录
[root@localhost soft]# wget https://www.kernel.org/pub/software/scm/git/git-2.15.1.tar.xz
[root@localhost soft]# tar -vxf git-2.15.1.tar.xz
[root@localhost soft]# cd git-2.15.1
[root@localhost git-2.15.1]# make prefix=/git all 编译 prefix指定目录
[root@localhost git-2.15.1]# make prefix=/git install 安装 prefix指定目录
[root@localhost git-2.15.1]# echo "export PATH=$PATH:/git/bin" >> /etc/profile 设置环境变量
[root@localhost git-2.15.1]# source /etc/profile 保证环境变量立即生效
4、如果上面下载执行报错,请使用最下面一行的语句
[root@localhost soft]# wget https://www.kernel.org/pub/software/scm/git/git-2.15.1.tar.xz
--2001-02-27 11:29:07-- https://www.kernel.org/pub/software/scm/git/git-2.15.1.tar.xz
Resolving www.kernel.org... 147.75.46.191, 2604:1380:4080:c00::1
Connecting to www.kernel.org|147.75.46.191|:443... connected.
ERROR: cannot verify www.kernel.org’s certificate, issued by “/C=FR/ST=Paris/L=Paris/O=Gandi/CN=Gandi Standard SSL CA 2”:
Issued certificate not yet valid.
To connect to www.kernel.org insecurely, use ‘--no-check-certificate’.
[root@localhost soft]# wget https://www.kernel.org/pub/software/scm/git/git-2.15.1.tar.xz --no-check-certificate
5、查看最新的git版本
[root@localhost ~]# git --version
git version 2.15.1
6、遇此问题的解决方法:修改系统时间就OK
Warning: File `../table/table.pro' has modification time 3.9e+08 s in the future
7、第二天打开服务器输入git仍然提示:-bash: git: command not found,解决方法:设置环境变量即可解决
echo "export PATH=$PATH:/git/bin" > /etc/profile.d/git.sh
source /etc/profile.d/git.sh
git --version