1

Recently I tried to use git in MacBook Pro with Sierra 10.12.5. The git was using without complaint in Mavericks, however, it gives problem in git push now.

Note

There are literally a number of similar and same problem in SO and google, but none of them worked for me.
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.

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

  2. Testing

    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:

    git clone git@github.com:bhishan2/practice.git.
    cd practice.
    touch example.txt.
    git add example.txt.
    git commit -m "added a file"
    git push origin master.

Now I got the above error.

How can we solve this error?

Related links:
git: fatal: Could not read from remote repository
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

Help will be truly appreciated.

BhishanPoudel
  • 15,974
  • 21
  • 108
  • 169

2 Answers2

1

Last time I saw that error after a successful ssh -T github.com was in 2015

And the Hi USERNAME was not exactly the same as the intended GitHub account (here 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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

Based on the answer provided by @VonC,
I found my solution. Everything was good, actually, I had two GitHub accounts bhishan and bhishan2 and both have the repo called practice.

In this case, I was logged in from first GitHub account bhishan and cloned the repo practice from second GitHub account 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. 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.

BhishanPoudel
  • 15,974
  • 21
  • 108
  • 169