首页 > 解决方案 > 无法克隆 Git 存储库,即使我将公钥添加到 GIthub

问题描述

我买了一台新的 M1 Macbook Air,并开始在笔记本电脑上进行设置。我安装了 Git,并克隆了我的存储库

git clone git@github.com:xibotlab/homepage.git

然后出现了错误:

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我知道要解决这个错误我必须将 Git Public Key 添加到 Github,所以我输入了这个:

ssh-keygen -t ed25519 -C "xibotmoon@gmail.com"

我成功地将公钥添加到 Github。

但是即使我添加了公钥,上面也有错误。我在 Github 上搜索,但我无法解决这个问题,因为所有文件都说我必须添加公钥,我已经做到了!我该如何解决这个问题?

谢谢你。

标签: gitgithubclone

解决方案


首先尝试切换到 HTTPS,尤其是对于公共存储库:

git clone https://github.com/xibotlab/homepage.git

关于 SSH,请先测试 SSH 访问权限,然后再尝试克隆:

ssh -Tv git@github.com

如果您没有看到欢迎消息,但同样的 Permission Denied 错误,您将需要调查更多调试信息。


推荐阅读