Git"Could not read from remote repository.Please make sure you have the correct access rights."解決方案
我們在使用Git clone 或其他命令的時候,有時候會遇到這類問題,如圖:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: Could not read from remote
repository.Please make sure you
have the correct access rights and the repository exists.
出現這個問題是因為沒有在github賬號新增SSH key
1.在終端輸入。
ssh-keygen -t rsa -C "username" (注:username為你git上的使用者名稱)
如果執行成功。返回
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/username/.ssh/id_rsa):
Generating public/private rsa key pair.Enter file in which to save the key (/Users/username/.ssh/id_rsa):
首先,說明一下,這裡的username
然後,在這裡就是設定儲存地址了.我們直接按回車,會出現一下兩種情況的一種:
(1)如果正常執行的話,會出現
Enter passphrase (empty for no passphrase):
然後我們直接回車
(2)有的時候我們可能會出現
/Users/your username/.ssh/id_rsa already exists.
Overwrite (y/n)?
這說明你已經設定了儲存地址,我們輸入“y”覆蓋Overwrite (y/n)? y
回車
上面的任意兩種情況之後,會出現
Enter same passphrase again:
再次回車,這時候你會看見:Your identification has been saved in /Users/username/.ssh/id_rsa.
Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
The key fingerprint is:
58:42:8b:58:ad:4b:b5:b9:6d:79:bf:8c:f9:e2:2b:ed username
The key's randomart image is:
+--[ RSA 2048]----+
| ... |
| o oo. |
| . .ooo. |
| o o+ |
| . ..oS. |
| . . + . |
| . o . |
| . o+. |
| +E++. |
+-----------------+
這說明SSH key就已經生成了。檔案目錄就是:/Users/username/.ssh/id_rsa.pub.
我們執行cat命令檢視檔案的內容:
cat /User/username/.ssh/id_rsa.pub
這時候會看見:
ssh-rsa AAAAB3NzaC1yc2。。。。。。。。。
後面的內容我省略了(說明:ssh-rsa 後面的內容這就是你的SSH keys)
把顯示出來的SSH keys直接新增到github賬戶設定裡邊的SSH
keys
最後再執行git clone命令就可以了