1. 程式人生 > >使用git客戶端第一次git clone github com程式碼的方法

使用git客戶端第一次git clone github com程式碼的方法

                     

使用git客戶端第一次git clone github.com程式碼的方法

使用git-clone命令從github上同步github上的程式碼庫時,如果使用SSH連結,而你的SSH key沒有新增到github帳號設定中,系統會報下面的錯誤:

 

Permission denied (publickey).

   

fatal: Could not read from remote repository.

   

Please make sure you have the correct access rights

   

and the repository exists.

這時,需要在本地建立SSH key,然後將生成的SSH key檔案內容新增到github帳號上去。建立ssh key的過程如下:
輸入命令:ssh-keygen -t rsa -c "

[email protected]"

然後根據提示連按三次enter鍵,生成的SSH key檔案就儲存到C:\Users\Administrator.ssh資料夾下的id_rsa.pub檔案中。
如圖所示:
這裡寫圖片描述

用文字工具開啟id_rsa.pub檔案,複製其內容。將其貼上到github賬號下的SSH key中。
登陸自己的github賬號,選擇“setting”選項,新增SSH key.如圖所示:

這裡寫圖片描述
這裡寫圖片描述

然後就可以clone自己的github上的程式碼了。

git clone命令:git clone [email protected]:Jameszhjj/W3C.git

git add命令:git add -A

git commit命令:git commit -m " "

git  push命令:git push (origin master)(括號內可選)