报错是这个:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
首先我是在本地建了一个库 然后要推送到gitHub 上面。
按照命令
ssh-keygen -t rsa -C “email”
也生成了ssh key
然后在gitHub 上添加了这个key
然后我发现新增加的key图标是灰色的。
但是我没意识到这个问题,我接下来按照网上的教程,直接去
git push -u origin master
但是就是一直报错,连接不上啊。
Please make sure you have the correct access rightsand the repository exists.
怎么办?
最后找到了原因,原来在这之前还需要执行一个命令,把那个灰色的变为可以使用的。
ssh -T git@github.com
新添加到github上的秘钥左边的点一开始是灰色的,终端执行这个命令后,刷新网页会看到灰色点变成了绿色。
之后再执行
git push -u origin master
就没问题了。