[email protected]:权限被拒绝(公钥)。致命的:无法从远程存储库读取

问题描述 投票:1回答:1

我正在使用macOS Catalina。我已经在GitLab和SSH-key上有一个存储库。现在,我想从终端创建另一个存储库。我执行以下操作:

git config user.name my_name
git config user.email my_email
git remote add origin [email protected]:my_name/repo.git

然后我得到了:

Initialized empty Git repository in directory

到目前为止一切顺利。

git add .
git commit -m 'commit'
git push -u origin master

然后我收到以下错误:

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

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

然后,我进入已经拥有的存储库并尝试将其推送到那里,一切正常,因此我想我对SSH-key没问题。我知道这是互联网上一个非常普遍的问题,但是没有一个答案能解决我的问题。

gitlab ssh-keys git-push iterm git-init
1个回答
0
投票

首先,仅在git init .之后,而不是在git remote add origin ...之后,您应该获得“目录中的初始化的空Git存储库”

其次,从GitLab 10.5(Q1 2018)开始,您可以使用GitLab push to create a new project作为illustrated in this MR

第三,如果错误仍然存​​在,则说明密钥存在某种错误。用以下方法进行测试:

ssh -Tv [email protected]

git -c core.sshCommand="ssh -v" push -u origin master
© www.soinside.com 2019 - 2024. All rights reserved.