【问题标题】:How to fix the git error: Repository not found如何修复 git 错误:找不到存储库
【发布时间】:2021-04-07 08:01:00
【问题描述】:

我创建了一个新项目并尝试推送新的存储库。

我的做法是这样的:

git init
git remote add origin https://gitlab.com/test.dev/project1.git
git add .
git commit -m 'Initial commit'
git push origin master

这是错误:

remote: The project you were looking for could not be found.
fatal: repository 'https://gitlab.com/test.dev/project1.git/' not found

我已经尝试删除并重新申请仍然不起作用。

【问题讨论】:

  • 请再次确认该 URL 上存在这样的 repo。
  • @iBug 当我尝试公开时它可以工作,但是当我更改为私有时出现错误
  • 您是否尝试通过 ssh 而不是 https 推送(并事先设置 ssh 密钥)?

标签: git gitlab


【解决方案1】:

如果没有任何协议(ssh 和 https)有效并且存在这样的 repo,那么

this post找到答案。

只需将用户名添加到以下网址即可解决此问题,

之前: https://gitlab.com/gitlab_user/myrepo.git

之后: https://gitlabusername@gitlab.com/gitlab_user/myrepo.git

记住 'gitlabusername'你的 gitlab 用户名,第二个 gitlab_user 将是 项目所有者 所以完整网址为:https://your_gitlab_username@gitlab.com/repo_owner_gitlab_username/repo_name.git

【讨论】:

    【解决方案2】:

    如果你的仓库是私有的,你需要使用 ssh 看起来像git@gitlab.com:test.dev/project1.git
    替换您的远程来源会帮助您
    执行此操作的命令如下所示:
    git remote set-url origin git@gitlab.com:test.dev/project1.git

    【讨论】:

    • in case your repository is private, you need to use ssh => 我在 gitlab.com 上通过 https 使用私有存储库没有任何问题。如果有与 OP 的问题相关的特定案例迫使他使用 ssh,您应该在回答中解释这一点。就我而言,根据当前可用的信息,存储库根本不存在。
    猜你喜欢
    • 2018-12-09
    • 2021-03-11
    • 2021-09-23
    • 2013-08-30
    • 1970-01-01
    • 2016-04-27
    • 2020-04-01
    • 1970-01-01
    相关资源
    最近更新 更多