问题
我在从 bitbucket 中推送 或 pull 数据时遇到以下错误。
git fetch --all
Fetching origin
Forbidden
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我在 bitbucket 和 mac 上的 ~/.ssh/project_ssh_key
上有相同的 ssh key 。
我曾尝试修复它
我尝试创建一个新的 ssh 文件并使用以下命令使用它。
eval "$(ssh-agent -s)"
ssh-add -K ~/.ssh/my_project_new_private_key
我已经在 ** 个人设置 --> ssh key ** 中添加了 bitbucket 中新创建的 key 并粘贴了公钥,但没有成功。
我还尝试了 ssh -T git@bitbucket
并得到了输出
logged in as chakreshwar
You can use git or hg to connect to Bitbucket. Shell access is disabled
在我执行以下操作之前,一切都在使用旧 key
1. I realized that my RoR application is not using **.ruby-version** & **.ruby-gemset**
2. I created a new gemset & use that gemset.
3. Move all the references from default to newly created gemset.
4. Bundle install and rails s to make sure everything works.
5. Delete all the old git branches from local which are no longer in use.
最佳答案
首先检查您是否有 ~/.ssh/config
文件。
因为如果 ssh -T git@bitbucket
有效,这意味着您有一个引用正确私钥的 Host bitbucket
条目。
但在那种情况下,git remote -v 必须反射(reflect)实际使用该主机条目的 SSH URL:
bitbucket:<me>/<myrepo>
(假设你的配置文件也有一个 User git
行)
不是bitbucket.org
,而是bitbucket
。
所以:
cd /apth/to/local/repo
git remote set-url origin bitbucket:<me>/<myrepo>
关于ruby-on-rails - 无法在 bitbucket 上使用 ssh 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62513096/