git clone時錯誤解決方案--contos安裝git教程

錯誤信息

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章