使用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项目包就克隆下来了