我們在使用Gitclone 或其他命令的時候,有時候會遇到這類問題,如圖:
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.
出現(xiàn)這個問題是因為沒有在github賬號添加SSH key
解決方法如下:
1.在終端輸入。
ssh-keygen -t rsa -C "username" (注:username為你git上的用戶名)
如果執(zhí)行成功枫耳。返回
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是你電腦上的用戶名
然后迄薄,在這里就是設(shè)置存儲地址了.我們直接按回車,會出現(xiàn)一下兩種情況的一種:
(1)如果正常運行的話煮岁,會出現(xiàn)
Enter passphrase (empty for no passphrase):
然后我們直接回車
(2)有的時候我們可能會出現(xiàn)
/Users/your username/.ssh/id_rsa already exists.
Overwrite (y/n)?
這說明你已經(jīng)設(shè)置了存儲地址讥蔽,我們輸入“y”覆蓋
Overwrite (y/n)? y
回車
上面的任意兩種情況之后,會出現(xiàn)
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:edusername
The key's randomart image is:
+--[ RSA 2048]----+
|? ? ...? ? ? ? ? |
| ? o oo. ? ? ? ? |
|? . .ooo.? ? ? ? |
|? ? o o+ ? ? ? ? |
| ? . ..oS. ? ? ? |
|? ? . . + .? ? ? |
| ? ? ? . o . ? ? |
|? ? ? ? . o+.? ? |
| ? ? ? ? +E++. ? |
+-----------------+
這說明SSH key就已經(jīng)生成了冶伞。文件目錄就是:/Users/username/.ssh/id_rsa.pub.
我們執(zhí)行cat命令查看文件的內(nèi)容:
cat /User/username/.ssh/id_rsa.pub
這時候會看見:
ssh-rsa AAAAB3NzaC1yc2。步氏。响禽。。荚醒。芋类。。界阁。侯繁。
后面的內(nèi)容我省略了
(說明:ssh-rsa 后面的內(nèi)容這就是你的SSH keys)
把顯示出來的SSH keys直接添加到github賬戶設(shè)置里邊的SSH keys
最后再執(zhí)行g(shù)it clone命令就可以了