Git : fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists

change your ssh url by an http url for your remote 'origin', use:

> git remote set-url origin https://github.com/<user_name>/<repo_name>.git

It will ask for your GitHub password on the git push.


I asked in the discussion:

does ssh -T [email protected] ouput the same username (in Hi [My Username]!) as in the one used for the ssh url of your repo ([email protected]:username/repo.git)?

Sorry It not showing same name

That means somehow the credentials have changed.

One solution would be to at least copy %HOME%\.ssh\id_rsa.pub in the SSH keys section of the right GitHub account

The OP adds:

I am working on private repo. So In [email protected]:username/repo.git,

I replied:

If you were able to clone/push to that repo whose username is not your own GitHub account, that must be because you had your previous public ssh key added as a contributor to that repo by the repo's owner.

What next is to ask that same repo owner to add your current public ssh key %HOME%\.ssh\id_rsa.pub to the repo contributor list.
So check with the owner that you (meaning your public ssh key) are declared as a contributor.


Sometimes that (copying the pub ssh key to github/bitbucket) is not enough, particularly with Bitbucket. You also may need to check if your ssh is using the identity you expect rather than messing up with git remote

Check if the agent is using the same identity you pasted on github/bitbucket with ssh-add -l. If missing add it with

ssh-add ~/.ssh/id_rsa_my_git_identity

Further details: https://confluence.atlassian.com/bitbucket/configure-multiple-ssh-identities-for-gitbash-mac-osx-linux-271943168.html

Tags:

Git

Github