使用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:https://www.jianshu.com/p/7d57ce4147d3
ssh-keygen -t rsa -C "[email protected]"
其中要你輸入什麼,不管就一路回車
之後
ssh -v git@github.com
然後生成ssh公鑰
ssh-add ~/.ssh/id_rsa
在C:\Users\用戶名\.ssh
的文件夾下用記事本打開id_rsa.pub
然後複製全部文本
在github的網站裏面,進入Settings
添加sshkey就好了
之後正常配置config
$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"
執行git clone就行
$ git clone git@github.com:ruanyf/react-demos.git
然後阮一峯的react項目包就克隆下來了