【问题标题】:creating git repo and following instructions exactly giving me errors [duplicate]创建 git repo 并按照说明准确地给我错误 [重复]
【发布时间】:2021-07-07 19:27:55
【问题描述】:

我创建 git 存储库的常用方法是在网站上,然后克隆它们。 我想尝试另一种方式,在我的命令行中调用 git init。

所以我创建了一个没有任何内容的 repo,然后将这些步骤显示给我:

echo "# malware" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:S3j5b0/malware.git
git push -u origin main

太好了,我在命令行中完全按照这些说明进行操作,在最后一行中,我得到:

ask@garser:~/Git/malwa$ 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.

发生了什么?

【问题讨论】:

  • 您是否已将公钥上传到 GitHub?你有运行 SSH 代理吗?
  • 不,没有添加键

标签: git github


【解决方案1】:

您是否设置了您的 git 用户名和电子邮件?试试

git config --global user.name "Mona Lisa"
git config --global user.email "monalisa@gmail.com"

请确保您的用户名有权访问项目 repo!

如果这不起作用,则使用 HTTPS 网址编辑您的远程 origin

git remote set-url origin YOUR_HTTPS_URL

您可以在您的 repo 中找到如下 URL。

【讨论】:

  • 设置邮箱和用户不起作用,使用https也不行
猜你喜欢
  • 1970-01-01
  • 2021-03-01
  • 1970-01-01
  • 2018-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-03
  • 2014-01-01
相关资源
最近更新 更多