问题
I have a gitlab account on my mac which has the neccessary ssh key on it for my work account. I am trying to set up gitlab for all my personal projects. I have created a personal account on gitlab and created a ssh key.
I have edited the config file in ~/.shh/ to look like this
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
however I am not able to
git pull
as I get this error
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
if I type
ssh -T git@gitlab.com
I get
Welcome to GitLab, *my work account welcome*!
(the wrong account) Can anyone suggest any further steps I may take or see an error in my code?
回答1:
Check how does your .git/config
look like. I guess you don't have there url
starting with markbreadcreative.
and markgameforeverything.
prefixes.
To get your setup working, you need to modify the lines in your repo from
url = git@gitlab.com:whatever.git
to
url = git@markbreadcreative.gitlab.com:whatever.git
url = git@markgameforeverything.gitlab.com:whatever.git
respectively depending on which account you want to use. You can check your configuration using:
ssh -T git@markbreadcreative.gitlab.com
ssh -T git@markgameforeverything.gitlab.com
(should return different results). If not, post a verbose log from such commands (ssh -vvvT git@markgameforeverything.gitlab.com
).
来源:https://stackoverflow.com/questions/35297959/gitlab-with-two-ssh-keys-not-connecting-config-updated