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



我正在我的gitlab上设置一个新项目,但给了我一个致命的错误。由于我是 git 的新手,我只是在创建项目时遵循了存储库第一页上提供的所有说明,特别是在我正在尝试做的"推送现有文件夹"部分中。

我遵循了以下步骤:

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

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

fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.```
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 克隆它

答:我只是使用了错误的SSH密钥。
我所做的是(~/./ssh/config)编辑配置文件并确定要使用的密钥 - 在这种情况下,我在配置文件上使用的密钥以及我之前创建的密钥。

它对我有用。

最新更新