将本地项目推送到Git上的新项目时出错

时间:2019-10-08 14:59:31

标签: git gitlab

我正在gitlab上建立一个新项目,但给我一个致命错误。由于我是git的新手,因此在创建项目时,我只是按照存储库首页上提供的所有说明进行操作,特别是在“ Push an existing folder”部分中,这正是我要执行的操作。

我遵循了以下步骤:

1- created a SSH Key.
1.2- add the SSH Key to my account
2- git init
3- git remote add origin git@gitlab.com:<user>/<project>.git
4- git add .
5- git commit -m "Initial commit"
6- git push -u origin master

运行最后一个命令(6)时,我在控制台上收到此错误:

fatal: Could not read from remote repository.

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

2 个答案:

答案 0 :(得分:0)

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.``
  1. 您已经创建了ssh密钥-但是您是否已将其添加到gitlab中的帐户中?

    • 您可以使用以下命令验证ssh密钥是否已成功安装:

      ssh-keyscan gitlab.com
      
  2. 您已授予特定项目的权限吗?

    • 尝试克隆项目,并查看是否可以使用gitlab.com中的ssh URL对其进行克隆

答案 1 :(得分:0)

回答:我只是在使用错误的SSH密钥。
为了解决这个问题,我要做的就是编辑配置文件(~/./ssh/config)并确定要使用的密钥-在这种情况下,我在个人资料上使用的密钥是我以前创建的-。

对我有用。

相关问题