git - 权限被拒绝(公钥)。致命的 : Could not read from remote repository

标签 git ubuntu authentication github

我的 .git/config 中有以下内容

  1 [core]
  2     repositoryformatversion = 0
  3     filemode = true
  4     bare = false
  5     logallrefupdates = true
  6 [remote "origin"]
  7     url = git@github.com:monajalal/instagram-scraper.git
  8     fetch = +refs/heads/*:refs/remotes/origin/*

当我尝试将更改推送到 master 时,出现此错误:

$ git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.

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

这两个我都试过了,但还是报错:

2150  git remote set-url origin https://github.com/monajalal/instagram-scraper.git
 2154  git remote set-url origin git@github.com:monajalal/instagram-scraper.git


mona@pascal:~/computer_vision/instagram/instagram$ git log
commit e69644389a5c7be65ae6eae14d74065e221600cb
Author: Mona Jalal <jalal@cs.wisc.edu>
Date:   Wed Mar 1 17:48:00 2017 -0600

    scrapy for instagram skeleton
mona@pascal:~/computer_vision/instagram/instagram$ git status
On branch master
nothing to commit, working directory clean


$ uname -a ; lsb_release -a
Linux pascal 3.13.0-62-generic #102-Ubuntu SMP Tue Aug 11 14:29:36 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:    14.04
Codename:   trusty

请提出修复建议。

最佳答案

如果你没有properly setup your ssh key with GitHub ,您至少可以尝试使用 https(您提到的):

git remote set-url origin https://github.com/monajalal/instagram-scraper.git

这将询问您的用户名 (monajalal)/您的 GitHub 帐户的密码。

这会起作用,因为您拥有该存储库,这意味着您有权推送。
确保您已在本地进行提交以进行推送。

git add .
git commit -m "new commit"

git push -u origin master

您可能被迫执行 git push -f 的事实意味着目标(远程 GitHub 存储库)不是空的,而是包含它自己的提交(通常是 README .mdLICENSE 文件)

在那种情况下,最好使用 Git 2.9 or more , 做:

git config --global pull.rebase true
git config --global rebase.autoStash true

然后

git pull

这将在 GitHub 存储库(和获取的形式)中存在的那些之上重播您的本地提交。

然后一个简单的 git push -u origin master 就可以了。无需强制推送您的历史记录。

关于git - 权限被拒绝(公钥)。致命的 : Could not read from remote repository,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42544568/

相关文章:

git - 如何使用 git rebase 压缩 merge 周围的提交?

java - 如何在 docker-ubuntu 环境中设置 JAVA_HOME?

java - kubernetes集群中微服务之间如何进行JWT认证

git - 删除远程分支不会从 GitHub 中删除

git cherry-pick 在提交消息包含字符串/匹配正则表达式的范围内提交?

python - Ubuntu systemd 在 sudo 重启时退出错误

facebook-graph-api - 在 Cakephp 3x 中验证 Facebook 用户

c# - 如何使用 Firebase 创建统一的 Facebook 登录信息?

git - 直接在博客中显示 Github 存储库文件

linux - 如果bash脚本开始超时,如何退出?