首页 > 解决方案 > 无法推送到克隆的仓库

问题描述

从 Github 迁移到 Gitlab。克隆了存储库,设置了我的密钥等。我正在使用 GitKraken(之前使用的是 sourcetree,但已切换)。

问题:对 Gitlab 的推送尝试在一个 repo 上失败,并显示“git@gitlab.com: Permission denied (publickey)”。

我在 GitKraken 中创建了一个新的存储库,将其设置为私有,并且能够通过 ssh 将多个提交通过 GitKraken 推送到 Gitlab 而不会出现问题。这告诉我密钥或类似的东西没有实际问题,而且这个错误有点误导。两个 Repos 的设置相同,都是私有的,使用 SSH 并启用了 LFS。

当我推送到我从 github 克隆的 repo 时,它会抛出这个错误,告诉我一定有某种配置问题或其他东西,但我在这方面有点新手,不知道去哪里检查重置这种东西。

编辑:我在两个存储库上都运行了 ssh -vT git@gitlab.com。两者都以:

debug1: Authentications that can continue: publickey
debug1: Trying private key: /c/Users/crossmr/.ssh/id_dsa
debug1: Trying private key: /c/Users/crossmr/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/crossmr/.ssh/id_ed25519
debug1: Trying private key: /c/Users/crossmr/.ssh/id_xmss
debug1: No more authentication methods to try.
git@gitlab.com: Permission denied (publickey).

然而,我通过 gitkraken 创建的 repo 也返回了完全相同的输出,我可以很好地推送它。

出于测试目的,我生成了一组全新的密钥,现在在 bash 上收到:

$ ssh -T git@gitlab.com
Enter passphrase for key '/c/Users/crossmr/.ssh/id_rsa':
Welcome to GitLab, @crossmr!

但是,当我现在尝试使用 GitKraken 推送时,GitKraken 告诉我:“配置的 SSH 密钥格式无效”。

然而 bash 界面完全没有问题

Edit2:GUI 错误的图像

这是当前的 GUI 错误,而通过 bash 推送给了我:

$ git push Gitlab master
Enter passphrase for key '/c/Users/crossmr/.ssh/id_rsa':
Uploading LFS objects: 100% (18/18), 38 MB | 1.4 MB/s, done
Enumerating objects: 99, done.
Counting objects: 100% (99/99), done.
Delta compression using up to 4 threads.
Compressing objects: 100% (72/72), done.
Writing objects: 100% (72/72), 7.07 KiB | 452.00 KiB/s, done.
Total 72 (delta 38), reused 0 (delta 0)
To gitlab.com:crossmr/repo.git
4ccee92..d32d232  master -> master

标签: gitgitlabgitkraken

解决方案


推荐阅读