Git和Bitbucket:推送时未经授权

问题描述:

我已经在BitBucket中创建了一个存储库,并使用SSH对其进行了克隆.尝试push对BitBucket进行更改时,出现以下错误:

I have created a repository in BitBucket and have cloned it using SSH. When attempting to push my changes to BitBucket, I receive the following error:

未授权

致命:无法从远程存储库读取.

fatal: Could not read from remote repository.

我已经使用ssh-keygen创建了SSH密钥,并将生成的公共密钥复制到BitBucket.我已经下载了SourceTree,以查看是否有一些工具可能会有所帮助,但是它有同样的问题.

I have created an SSH key using ssh-keygen and have copied the resulting public key to BitBucket. I have downloaded SourceTree to see if a bit of tooling might help, but it has the same problem.

我已经尝试修复了几个小时,不想再浪费时间了.令人惊讶的是,在Google上搜索时,我找不到任何存在类似问题甚至错误消息的人.

I've been trying to fix this for hours now and don't want to waste any more time on it. Surprising, I couldn't find anyone with a similar issue or even the same error messages when searching on Google.

请帮助!我在Mac OS X上运行,并尝试从Keychain Access中删除GitHub凭据,但这不能解决问题.有人知道我可能在做错什么吗?

Please help! I am running on Mac OS X and have tried deleting GitHub credentials from Keychain Access but this hasn't solved the issue. Does anyone know what I might be doing wrong?

我在GitHub上使用了完全相同的客户端配置,并且没有遇到任何问题,因此我怀疑是我遗漏了BitBucket上的某些配置.

I have used exactly the same client-side configuration with GitHub, and ran into no issues, so I'm suspecting it's some configuration on BitBucket that I'm missing.

只是遇到了同样的问题并解决了.

Just had the same issue and solved it.

我的问题是我通过该存储库的设置"将生成的公共ssh密钥添加到了该存储库本身.

My issue was that I added the generated public ssh key to the repo itself through the 'settings' of that repo.

解决方案是从存储库本身中删除ssh密钥.点击您的帐户.通过帐户的设置"添加ssh密钥.

The solution was to delete the ssh key from the repo itself. Click on your account. Add the ssh key through 'settings' of your account.