git - Bitbucket/SourceTree 问题 > 无法从远程存储库读取

标签 git ssh bitbucket atlassian-sourcetree

我正在使用 SourceTree 并尝试推送我对文件所做的一些更改。我有一个连接到 SourceTree 的 BitBucket 帐户。当我去 push 更改时,通常一切正常,但今天我遇到了问题。我收到以下错误(也像这样重复多次)。

Sourcetree error message

git --no-optional-locks -c color.branch=false -c color.diff=false -c color.status=false -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags origin refs/heads/master:refs/heads/master 
Pushing to bitbucket.org:<username>/<folder>
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ee89879aae8c879a8c9b8d858b9ac0819c89" rel="noreferrer noopener nofollow">[email protected]</a>: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Pushing to bitbucket.org:<username>/<folder>
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e98e809da98b809d8b9c8a828c9dc7869b8e" rel="noreferrer noopener nofollow">[email protected]</a>: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Pushing to bitbucket.org:<username>/<folder>
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="afc8c6dbefcdc6dbcddaccc4cadb81c0ddc8" rel="noreferrer noopener nofollow">[email protected]</a>: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Pushing to bitbucket.org:<username>/<folder>
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="05626c7145676c716770666e60712b6a7762" rel="noreferrer noopener nofollow">[email protected]</a>: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Completed with errors, see above

出于隐私原因,我删除了用户名和文件夹/路径。到目前为止,我尝试解决此错误的方法是使用终端创建一个新的 ssh key ,如标题“在 macOS/Linux 上设置 SSH”下的 this article 中所述。我确保将此新 key 添加到 BitBucket 中的个人资料设置中,而不是存储库设置中,但它仍然显示相同的错误。我还尝试在 Sourcetree 中断开我的 BitBucket 帐户,退出程序,然后重新连接我的帐户,但没有成功。

还有什么我可以尝试解决这个问题吗?我不熟悉使用命令行,因此如果这是解决方案的一部分,我可能需要更多解释。

最佳答案

I made sure I added this new key to my profile settings in BitBucket, not my repository settings

实际上,您还需要将您的私钥注册到您的SourceTree配置中,如shown here (对于 Windows,但同样的想法也适用于 Linux):

Tools > Options > General > SSH Client Configuration, I had to point it to the id_rsa key, and select OpenSSH as the SSH Client

/image/2fGKy.png

OP 建议使用“Set up an SSH key ”作为官方文档。

关于git - Bitbucket/SourceTree 问题 > 无法从远程存储库读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70178143/

相关文章:

svn - 如何使用 Git 作为内容分发网络

git - 我可以让 git 告诉我一个用户修改过的所有文件吗?

git - 'git 子模块更新 --init --recursive' VS 'git submodule foreach --recursive git submodule update --init'

linux - 创建独立于调用 Bash 脚本的 SSH 连接

Docker 标签在 Bitbucket 管道中的步骤之间丢失

Github:重置为之前的提交

windows - Git bash 无法访问新机器上的主目录

linux - 在脚本中执行 ssh 命令

git - 一些提交在两个分支上。为什么?

git - 如何获取另一个远程存储库?