使用 git clone 时如何修复“找不到您要查找的项目”

tij*_*ter 51 git project cloning git-bash gitlab

我正在尝试将一个项目从 gitlab 克隆到我的本地机器。我已被授予开发人员权限,并使用命令 'git clone

  • 没有任何协议有效(ssh 和 https 都无效)

我收到的错误消息:

remote: The project you were looking for could not be found.
fatal: repository 'https://gitlab.com/KZA_Connected/skilltree.git/' not found
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激。

Abd*_*han 69

我通过简单地将用户名添加到 url 来解决这个问题,如下所示,

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

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

  • 谢谢。这对我有用。请记住“gitlabusername”是您的 gitlab 用户名,第二个 gitlab 用户名将是项目所有者 gitlab,因此总 URL 将为 https://your_gitlab_username@gitlab.com/repo_owner_gitlab_username/repo_name.git (10认同)
  • 2020 年了,GitLab 还没有修复页面上的按钮,将用户名包含在 url 中以复制粘贴到“git clone”吗? (3认同)

Abd*_*eed 32

今天,我遇到了同样的问题。回购在我的家用机器上运行良好,但是当我在其他机器上尝试相同的回购时,我开始面临同样的错误。我正在使用以下网址

https://gitlab.com/{gitlab_user}/project_repo.git
Run Code Online (Sandbox Code Playgroud)

现在我将上面的 URL 更改为下面

https://{gitlab_user}@gitlab.com/gitlab_user/project_repo.git
Run Code Online (Sandbox Code Playgroud)

它对我有用。在以下 URL 中找到了上述解决方案

https://medium.com/@imstudio/gitlab-the-project-you-were-looking-for-could-not-be-found-issue-685944aa5485
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助其他人。


小智 15

在 mac osx 上,这通常意味着您的 ssh 凭据未加载。暴力破解:

cd ~/.ssh
ssh-add *
Run Code Online (Sandbox Code Playgroud)

每次我的 Macbook 重新启动时,我都必须这样做。


Sam*_*lwe 15

如果您(像我一样)添加了多个 ssh 密钥,解决方案是明确声明远程主机应使用哪个密钥。

根据您的用例,将以下行添加到 ~/.ssh/config 文件中:

Host bitbucket.org
User git
IdentityFile ~/.ssh/id_rsa

Host gitlab.com
User git
IdentityFile ~/.ssh/id_ed25519
Run Code Online (Sandbox Code Playgroud)


小智 11

首先验证您的凭据是否正确。

git config user.email
git config user.name
Run Code Online (Sandbox Code Playgroud)

如果它们正确,请尝试username@在存储库地址之前附加您的地址。

例如,而不是

git clone https://repo.abc.com/projectname.git 
Run Code Online (Sandbox Code Playgroud)

尝试

git clone https://username@repo.abc.com/projectname.git
Run Code Online (Sandbox Code Playgroud)

  • `git config` 不是凭证。它们只是标记您本地提交的本地标签。 (4认同)

Man*_*R S 9

如果您面临新回购的问题

只需简单地将 gitlab 默认 https url 从https://gitlab.com/rscodelab/project.git更改为 https://rscodelab@gitlab.com/rscodelab/project.git

例如

git clone https://gitlab.com/gitlabusername/project.git

git clone https://gitlabusername@gitlab.com/gitlabusername/project.git


小智 8

我解决了上面的问题

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

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

解释:

输入您的gitlabUsername代替<gitlabusername>.

现在,它会询问您帐户的 gitlab 密码。输入正确的密码,即可成功克隆项目。


Man*_*R S 7

简单回答:使用以下命令重置您已经存在的原点。

git remote set-url origin https://gitlabUsername@gitlab.com/some-group/project.git

对你来说,

git remote set-url origin https://gitlabUsername@gitlab.com/KZA_Connected/skilltree.git
Run Code Online (Sandbox Code Playgroud)

git remote -v (检查是否反映了更改),然后

git push origin master

完成的。

如果是之后的第一次 git init

然后

git remote add origin https://gitlabUsername@gitlab.com/gitlabUsername/project_repo.git

因为git remote add origin https://gitlab.com/gitlabUsername/project_repo.git行不通,所以改用上面的。

如果仍然出现错误,则通过以下操作删除远程源并再次添加一个新的

git remote remove origin


Tom*_*cik 7

我有两个 gitlab 帐户。对于两者,我都使用 ssh 密钥。两者都由 gitlab 托管(不是自托管)。

当你跑

ssh -T git@gitlab.com
Run Code Online (Sandbox Code Playgroud)

它将返回您的用户名。

Welcome to GitLab, @username1!
Run Code Online (Sandbox Code Playgroud)

我为@username1 和@username2 使用ssh。它默认为找到的第一个 ssh。所以,AFAIK,不可能有两个 ssh 帐户。

我的解决方案是从我没有使用的 gitlab 帐户 rm ssh 密钥。

  • 您可以设置主机名别名以使用不同帐户的密钥,请参阅https://gist.github.com/oanhnn/80a89405ab9023894df7 (7认同)
  • +1,因为这可能会在多个 gitlab 用户冲突的情况下有所帮助,我在其他地方读过相关内容,这可能是一个很好的解决方法,但尚未进行测试。 (4认同)
  • 除了 Eliot 在 GitHub 上使用别名的评论之外,GitLab 上也可以实现类似的操作。在 ssh 配置中分配别名(“Host USERNAME.gitlab.com”)后,您可以例如:使用 `git@USERNAME.gitlab.com:REPO_OWNER/REPO.git` 进行克隆 请参阅:https://docs.gitlab.com/ee/ssh/ (3认同)
  • 这是一个很好的答案,帮助我理解了这个问题。 (2认同)

Han*_*bib 6

Windows 上有凭据管理器,其中包含有关主机凭据的详细信息,这里是凭据管理器的 ss 在此处输入图片说明

  1. 首先,请确保您拥有相同的用户凭据,这些凭据可以访问您尝试克隆的存储库。如果您有正确的凭据

然后试试这个 url 格式化程序

https://{username}@gitlab.com/username/repo-name.git
Run Code Online (Sandbox Code Playgroud)

在你的情况下,它会是这样的

'https://username@gitlab.com/KZA_Connected/skilltree.git/'
Run Code Online (Sandbox Code Playgroud)

我能够解决删除我的凭据并再次添加它们的问题我希望这也能帮助其他人

-- 重要说明这个凭证管理器保存您的全局凭证,您也可以使用 git config 设置您的本地凭证

git config --local user.name "Your name"
Run Code Online (Sandbox Code Playgroud)
git config --local user.email "Your email"
Run Code Online (Sandbox Code Playgroud)
git config --local credential.helper "store"
Run Code Online (Sandbox Code Playgroud)

如果您设置credential.helper为存储,则在当前本地 git 范围内,每次您执行拉、推等操作时,它都会询问您密码

如果你想重置 credential.helper,那么只需将它设置回manager 它就会像以前一样正常工作


skm*_*skm 6

将用户名放在 url 之前,如下所示:

git clone https://username@repo.abc.com/projectname.git
Run Code Online (Sandbox Code Playgroud)

相应地将 git 添加到现有文件夹:

git remote add origin https://username@repo.abc.com/projectname.git
Run Code Online (Sandbox Code Playgroud)


小智 5

如果添加 ssh 密钥不起作用,请按照以下步骤操作 -

eval "$(ssh-agent -s)"
Run Code Online (Sandbox Code Playgroud)

然后添加ssh密钥

ssh-add ~/.ssh/<id_rsa>
Run Code Online (Sandbox Code Playgroud)


tij*_*ter 4

解决方案:这是由于我的 Windows 凭据被设置为其他电子邮件帐户。

  • 如果有人不知道如何更改凭据,请检查此答案 /sf/answers/4472961181/ (2认同)