2017-02-24 186 views
2

我試圖克隆一些存儲庫,但始終得到相同的錯誤。我在哪裏可以找到關於這個錯誤的更多信息(錯誤日誌文件或類似的東西),或者有人知道什麼是錯的?無法使用git克隆任何存儲庫

# git clone http://github.com/creationix/nvm.git .nvm 
Initialized empty Git repository in /home/marcin/.nvm/.git/ 
error: while accessing http://github.com/creationix/nvm.git/info/refs 

fatal: HTTP request failed 

# git clone https://gitlab.com/jmis/exilecraft.git 
Initialized empty Git repository in /home/marcin/exilecraft/.git/ 
error: while accessing https://gitlab.com/jmis/exilecraft.git/info/refs 

fatal: HTTP request failed 

我使用CentOS的6.8和Git 1.7.1 ----------編輯
升級後

GIT中2.12.0我有錯誤信息:

# git clone https://github.com/creationix/nvm.git .nvm 
Cloning into '.nvm'... 
fatal: unable to access 'https://github.com/creationix/nvm.git/': Problem with the SSL CA cert (path? access rights?) 
+0

作爲一個數據點,在CentOS 6.8下使用git 1.7.1,我可以克隆第二個URL而不會出現問題,並且如果將'http://'更改爲'https:// '。如果我使用更新版本的'git',問題會完全消失。 – larsks

+0

我嘗試更新git到最新版本,但'git clone'不適用於我:/ – MastaBot

回答

3

該錯誤是HTTPS cloning errors

明確說明根據確切的錯誤消息,試圖在URL中您的用戶名,克隆可以幫助:

git clone https://<username>@github.com/<username>/<repo.git> 

但最好,你應該recompile and install a more recent version of Git

使用Git版本2.12.0,該錯誤信息是:

fatal: unable to access 'https://github.com/creationix/nvm.git/': 
Problem with the SSL CA cert 

確保您已安裝的證書:

sudo yum reinstall openssl ca-certificates -y 

此修復程序的手動版本是:

mkdir -p /etc/pki/tls/certs 
curl https://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/ca-bundle.crt 
git config --global http.sslcainfo /etc/pki/tls/ca-bundle.crt 
git config -l 

另外approach is described here

mkdir /usr/src/ca-certificates && cd /usr/src/ca-certificates 
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/ca-certificates-2015.2.6-65.0.1.el6_7.noarch.rpm 
rpm2cpio ca-certificates-2015.2.6-65.0.1.el6_7.noarch.rpm | cpio -idmv 
cp -pi ./etc/pki/tls/certs/ca-bundle.* /etc/pki/tls/certs/ 
+0

我得到了'致命的:HTTP請求失敗',現在我試着重新編譯Git – MastaBot

+0

@MastaBot你在你的最新評論中提到已經更新了git到最新的回覆,但是你得到了什麼錯誤信息? – VonC

+0

現在我有Git版本2.12.0,現在仍然有錯誤,現在錯誤消息是致命的:無法訪問'https://github.com/creationix/nvm.git/':SSL CA證書(路徑?訪問權限?)' – MastaBot

2

可能有多種原因(代理,防火牆,公司策略和更多)。
據我所知github上已經刪除的支持,爲http,現在只支持https

更改協議,SSH和它沒有任何問題的工作。

有關於如何做到這一點非常詳細的文件。
https://help.github.com/articles/connecting-to-github-with-ssh/

總結它:

  • 生成ssh密鑰本地
    開放GIT-的bash /終端和生成密鑰ssh-keygen
  • 複印鍵cat ~/.ssh/id_rsa.pub
  • 開放的git轂ANS粘貼鍵在您的配置文件設置下
  • 克隆與ssh url而不是http/https。

登錄到您的帳戶GitHub的

  • 在任何頁面的右上角,點擊您的個人資料照片,然後單擊設置

enter image description here

  • 在用戶設置側邊欄,點擊SSH和GPG鍵

enter image description here

  • 點擊新SSH密鑰添加SSH密鑰

enter image description here

  • 粘貼您的鑰匙插入鑰匙領域

enter image description here

  • 點擊添加SSH密鑰

enter image description here

  • 如果出現提示,確認您的GitHub的密碼。

enter image description here

+0

在github上添加SSH密鑰後我仍然收到相同的錯誤 – MastaBot

+0

您是否參與了該項目?如果它是一個私人回購,你必須作出貢獻來克隆它。 – CodeWizard

+0

我只希望更新我的nvm(節點版本管理器)和所有(或許多指令如何做到這一點''git clone http:// github.com/creationix/nvm.git' – MastaBot