更改特定项目中的 git 个帐户

Change git account in specific project

我的 BitBucket 帐户已为我的 git 个项目全局安装。

现在我必须使用我在学校的 Gitlab 帐户进行项目。当我尝试克隆存储库时出现错误:

Cloning into '*****'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the co

我认为这是因为我尝试使用未连接到此 Gitlab 存储库的 BitBucket 帐户进行克隆。

有人知道如何只更改此项目的配置吗?

感谢您的帮助! :)

您需要在 GitLab 帐户中添加 ~/.ssh/id_rsa.pub

转到GitHub Profile | SSH Keys | Add SSH Key 使用浏览器。然后使用 ~/.ssh/id_rsa.pub.

添加一个新的 SSH 密钥

Create and Add SSH key


或者,将您的克隆 URL 从 SSH 更改为 https。然后用你的 GitLab username/password.

克隆 repo

解决方案是按照@sajib khan 的建议添加您的 ssh 密钥。

如果你不想将你的ssh密钥添加到gitlab,你可以看看gitlab是否允许你通过http(s)连接。如果是这样,那么您可以使用 http(s) link 克隆存储库。如果是这种情况,那么 gitlab 有时可能会要求您登录。