无法从 Gitlab 克隆存储库:权限被拒绝,请重试

Unable to clone repository from Gitlab: Permission denied, please try again

我正在尝试从我的 Gitlab 帐户克隆一个空存储库。我只是使用 SSH:

下我的 Gitlab 存储库页面上显示的地址
git@gitlab.xxx.com:USERNAME/project-name.git

然后只需在一个空文件夹中尝试此操作,但它一直告诉我权限被拒绝,要求重试:

git clone git@gitlab.xxx.com:USERNAME/project-name.git
Cloning into 'project-name'...
git@gitlab.xxx.com's password:
Permission denied, please try again.
git@gitlab.xxx.com's password:

当我为克隆选择 https 地址时,消息如下:

remote: HTTP Basic: Access denied
fatal: Authentication failed for ....

我可以使用该密码登录到 Gitlab 主页,所以我不知道到底出了什么问题。

怎么了?如何解决?

Gitlab 上的 ssh 身份验证需要 ssh 密钥。您需要生成一个,具体取决于您的主机,windows、linux 或其他。然后您需要将密钥添加到您的帐户。

您可以在这里找到所有需要的信息:https://gitlab.com/help/ssh/README.md

如果您想使用 http 登录,您应该切换到 http 身份验证。在仓库地址的左边有一个菜单,你可以选择ssh 或http。使用后者

因为我在 Windows,this answer 是救命恩人:

每次我被迫更改 Windows 密码时都会发生这种情况,none 以上答案对我有帮助。

尝试以下适合我的解决方案:

转到 Windows 凭据管理器(按 Windows Key 并键入 credential)以编辑 git 条目 Windows Credentials。用新密码替换旧密码。