带有两个未连接的 ssh 密钥的 gitlab(已更新配置)

gitlab with two ssh keys not connecting (config updated)

我的 mac 上有一个 gitlab 帐户,上面有我的工作帐户所需的 ssh 密钥。我正在尝试为我所有的个人项目设置 gitlab。我已经在gitlab上创建了一个个人帐户并创建了一个ssh密钥。

我已将 ~/.shh/ 中的配置文件编辑为如下所示

Host markgameforeverything.gitlab.com
    HostName gitlab.com
    User git
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/personal.pub

Host markbreadcreative.gitlab.com
    HostName gitlab.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa.pub

但是我不能

git pull

当我收到这个错误时

GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists

如果我输入

ssh -T git@gitlab.com

我明白了

Welcome to GitLab, *my work account welcome*!

(错误的帐户) 任何人都可以建议我可以采取的任何进一步步骤或看到我的代码中的错误吗?

看看你的 .git/config 长什么样。我猜你没有 urlmarkbreadcreative.markgameforeverything. 前缀开头。

为了使您的设置正常工作,您需要修改来自

的代码库中的行
url = git@gitlab.com:whatever.git

url = git@markbreadcreative.gitlab.com:whatever.git
url = git@markgameforeverything.gitlab.com:whatever.git

分别取决于您要使用哪个帐户。您可以使用以下方法检查您的配置:

ssh -T git@markbreadcreative.gitlab.com
ssh -T git@markgameforeverything.gitlab.com

(应该return不同的结果)。如果没有,post 来自此类命令的详细日志 (ssh -vvvT git@markgameforeverything.gitlab.com)。