由於系統重起了,當然本地的倉儲和SSH生成的密鑰就都沒有了,這時如何在本地pull自己在GitHub上的倉儲呢?
由於系統重裝,~/.ssh文件肯定就沒有了,這時候就需要重新生成公鑰和密鑰,
ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.Enter file in which to save the key (/home/XXX/.ssh/id_rsa):
Created directory '/home/XXX/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/XXX/.ssh/id_rsa.
Your public key has been saved in /home/XXX/.ssh/id_rsa.pub.
The key fingerprint is:
79:3c:8c:e7:3e:57:8a:59:36:4d:4c:09:59:d3:8b:df [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
| .+oo |
| . o..|
| o. .|
| = .o. |
| S * o. .|
| + .+ o.E|
| .= + |
| .+ o |
| .o |
+-----------------+
需要輸入時直接enter,命令行中的郵箱是你在GitHub上留的郵箱,這樣就生成類型爲rsa的密鑰對。然後把id_rsa.pub裏的公開密鑰拷貝到GitHub上即可。Account Setting—>SSH Keys—>Add SSH Key即可。最後用ssh -T [email protected]驗證。輸出
Hi XXX! You've successfully authenticated, but GitHub does not provide shell access.即說明設置成功。
其實這些都跟正題沒有什麼關係,設置SSH只是訪問GitHub的一種方式,平常我們使用http的方式是最多的,言歸正傳,當我們需要GitHub上的倉儲時,我們新建一個文件夾,首先git init初始化git,然後git pull https://github.com/XXX/Snake.git,這樣就會把倉儲拷貝下來,這樣就可以操作了。