I can't push to Bitbucket and this is the error message:
> git push origin master:master
Unauthorized
fatal: Could not read from remote repository.Please make sure you have the correct access rights and the repository exists.
Debugging, I receive this message when I ssh to bitbucket:
> ssh -T bitbucket.org
authenticated via a deploy key.You can use git or hg to connect to Bitbucket. Shell access is disabled.
This deploy key has read access to the following repositories:
my-username/my-repository
The read access part of this message is suspicious.
PS: I know there are dozens of similar questions, but I couldn't find the exact error message here and only got the solution outside. That's why I'm self answering this to help others.
The Git “fatal: Could not read from remote repository” error occurs when there is an issue authenticating with a Git repository. This is common if you have incorrectly set up SSH authentication. To solve this error, make sure your SSH key is in your keychain and you connecting to a repository using the correct URL.
Note: The “fatal: 'origin' does not appear to be a git repository” error occurs when you try to push code to a remote Git repository without telling Git the exact location of the remote repository. To solve this error, use the git remote add command to add a remote to your project.
The “… does not a appear to be a git repository” error is triggered when you try to clone, or run other commands, in a directory that is not recognized as a Git repository. The directory or remote file path might not have initialized Git, or the file path you are trying to access as an active repository is incorrect.
I was able to solve this using this suggestion:
- Remove the SSH key from the repo. (Click on repo name > Settings > Access Keys)
- Add SSH key to Account settings SSH keys. (Click on your avatar > Personal Settings > SSH Keys)
So, adding the keys under the repo only gives you a read-only access. For read and write access, you need to add your keys under your account.
To be fair, Bitbucket warns about the read-only access when adding the key to the repo:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With