首页 > 解决方案 > 权限被拒绝(公钥)&请确保您具有正确的访问权限并且存储库存在

问题描述

我尝试使用命令创建新存储库,但出现以下错误,我该如何解决?`我的窗口是 windows-7 pro

       PS C:\Users\Naing Min Zaw\Desktop\learningGit> git push -u origin main
       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.

我在powershell中使用这个命令

git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:NaingMinZaw/learningGit.git
git push -u origin main

标签: gitgithub

解决方案


检查输出

git -c "core.sshCommand='ssh -Tv'" push -u origin main

这将显示在推送期间 SSH 查找了哪个 SSH 密钥。

如果您没有 SSH 密钥,请生成一个并将公钥添加到您的GitHub 配置文件中。


推荐阅读