简体   繁体   English

git push在MacOS Sierra 10.12.5中失败

[英]git push failed in MacOS Sierra 10.12.5

Recently I tried to use git in MacBook Pro with Sierra 10.12.5. 最近,我尝试在带有Sierra 10.12.5的MacBook Pro中使用git。 The git was using without complaint in Mavericks, however, it gives problem in git push now. git在Mavericks中使用时毫无怨言,但是,现在在git push中出现了问题。

Note 注意

There are literally a number of similar and same problem in SO and google, but none of them worked for me. 从字面上看,SO和Google中存在许多相似和相同的问题,但是它们都不适合我。
If anybody suggests a link that solves my problem I will happily remove my question, no need to downvote, this problem is taking a lot of time for me. 如果有人提出了可以解决我问题的链接,那么我会很乐意删除我的问题,而无需投票,这个问题对我来说会花费很多时间。

This seems to be a stupid problem, just not being able to push to git hub repo, but admit it nor not, this is the problem that is bothering me in the mean time. 这似乎是一个愚蠢的问题,只是无法推送到git hub仓库,但也不允许这样做,这是困扰我的问题。

Thanks for your help, if you can help. 感谢您的帮助,如果可以的话。

Error: 错误:

ERROR: Permission to XXX.
fatal: Could not read from remote repository.

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

Things Done So Far: 到目前为止完成的事情:

  1. Copied contents of ~/.ssh/id_rsa.pub to GITHUB/Settings/SSH and GPG keys/ New Key ~/.ssh/id_rsa.pub内容已~/.ssh/id_rsa.pub到GITHUB / Settings / SSH和GPG密钥/新密钥

  2. Testing 测试

    ssh -T git@github.com ssh -T git@github.com

Gives: 得到:

Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.
  1. Then I cloned a practice repo from my GitHub account: 然后,我从GitHub帐户克隆了一个练习仓库:

    git clone git@github.com:bhishan2/practice.git. git clone git@github.com:bhishan2 / practice.git。
    cd practice. cd练习。
    touch example.txt. 触摸example.txt。
    git add example.txt. git添加example.txt。
    git commit -m "added a file" git commit -m“添加了文件”
    git push origin master. git push原始主机。

Now I got the above error. 现在我得到了上面的错误。

How can we solve this error? 我们如何解决这个错误?

Related links: 相关链接:
git: fatal: Could not read from remote repository git:致命的:无法从远程存储库读取
https://community.atlassian.com/t5/Bitbucket-questions/git-pull-fatal-Could-not-read-from-remote-repository/qaq-p/122111 https://community.atlassian.com/t5/Bitbucket-questions/git-pull-fatal-Could-not-read-from-remote-repository/qaq-p/122111
https://github.com/jakubroztocil/cloudtunes/issues/23 https://github.com/jakubroztocil/cloudtunes/issues/23

Help will be truly appreciated. 帮助将不胜感激。

Last time I saw that error after a successful ssh -T github.com was in 2015 上次在ssh -T github.com成功后我看到该错误是在2015年

And the Hi USERNAME was not exactly the same as the intended GitHub account (here bhishan2 ) Hi USERNAME与预期的GitHub帐户(此处为bhishan2 )并不完全相同。

That means the cloned repo bhishan2/practice can be cloned, but cannot be pushed to, because the ssh key authenticates as the wrong owner. 这意味着可以bhishan2/practicebhishan2/practice ,但是不能将其推入,因为ssh密钥将身份验证为错误的所有者。

Based on the answer provided by @VonC, 根据@VonC提供的答案,
I found my solution. 我找到了解决方案。 Everything was good, actually, I had two GitHub accounts bhishan and bhishan2 and both have the repo called practice . 一切都很好,实际上,我有两个GitHub帐户bhishanbhishan2,并且都拥有一个名为实践的存储库

In this case, I was logged in from first GitHub account bhishan and cloned the repo practice from second GitHub account bhishan2 . 在这种情况下,我从第一个GitHub帐户bhishan登录,并从第二个GitHub帐户bhishan2复制了回购实践

All of my settings were for the first account, so I had got the issue. 我所有的设置都是针对第一个帐户的,所以我遇到了问题。

I had tried all the day (more than 5/6 hours) yesterday, and posted the question in the midnight and went for sleeping. 昨天我整天(超过5/6小时)尝试了此问题,并在午夜发布了问题并入睡。 This morning I saw the answer. 今天早上我看到了答案。

Thanks for comments and the answer. 感谢您的评论和答复。

I am keeping this answer, just for the reference so that in future if anybody encounters the same problem will be benefitted. 我保留此答案,仅供参考,以便将来在任何人遇到相同问题时都将从中受益。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM