Git 克隆 - 未找到存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25947059/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:30:25  来源:igfitidea点击:

Git Clone - Repository not found

gitgithub

提问by Max

git clone <url>

gives the message fatal: repository 'url' not found

给出消息致命:未找到存储库“url”

I tried the options in the link, but it didn't work.

我尝试了链接中的选项,但没有用。

采纳答案by Kai Mattern

Most probably, your URL is not valid.

很可能,您的 URL 无效。

If it is a http/https URL, you can quickly check, by hammering the URL into a browser. If that does not display anything at all, you know that the URL is invalid.

如果是 http/https URL,您可以通过将 URL 敲入浏览器来快速检查。如果那根本没有显示任何内容,您就知道该 URL 无效。

I assume you are speaking of a remote repository. The URLs should look somewhat like these:

我假设您说的是远程存储库。这些 URL 应该看起来像这样:

https://github.com/user/repo2.git if you're using HTTPS
[email protected]:user/repo2.git if you're using SSH

回答by Christian Fries

As mentioned by others the error may occur if the url is wrong.

正如其他人所提到的,如果 url 错误,则可能会发生错误。

However, the error may also occurif the repo is a private repo and you do not have access or wrong credentials.

但是,如果存储库是私有存储库并且您没有访问权限或凭据错误,也可能会发生该错误。

Instead of

代替

git clone https://github.com/NAME/repo.git

git clone https://github.com/NAME/repo.git

try

尝试

git clone https://username:[email protected]/NAME/repo.git

git clone https://username:[email protected]/NAME/repo.git



You can also use

你也可以使用

git clone https://[email protected]/NAME/repo.git

git clone https://[email protected]/NAME/repo.git

and git will prompt for the password (thanks to leanne for providing this hint in the comments).

并且 git 将提示输入密码(感谢 Leanne 在评论中提供此提示)。

回答by tsafrir

On macOS it's possible that the cached credentials in the Keychain that git is retrieving are wrong. It can be an outdated password or that it used the wrong credentials.

在 macOS 上,git 检索的钥匙串中的缓存凭据可能是错误的。它可能是过时的密码或使用了错误的凭据。

To update the credentials stored in OS X Keychain

更新存储在 OS X Keychain 中的凭据

Follow the instructions at:

按照以下说明操作:

https://help.github.com/articles/updating-credentials-from-the-osx-keychain/

https://help.github.com/articles/updating-credentials-from-the-osx-keychain/

If you want to verify this is the problem you can run clone with tracing.

如果您想验证这是问题所在,您可以使用跟踪运行克隆。

$ GIT_CURL_VERBOSE=1 git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY

Look for the header line "Authorization: Basic BASE64STRING" .
Take the base64 string and decode it to check what username:password was used.

查找标题行 "Authorization: Basic BASE64STRING" 。
获取 base64 字符串并对其进行解码以检查使用的用户名:密码。

$ echo <the key> | base64 --decode

Verify it's the right username password you expected to use.

验证它是您希望使用的正确用户名密码。

回答by Vikas Chandra

I was also having same issue. I was trying to clone the repo which was private and my git installed in osx has keychain which was not allowing me to clone the repo...

我也有同样的问题。我试图克隆私有的仓库,而我安装在 osx 中的 git 有钥匙串,这不允许我克隆仓库......

I tried

我试过

git clone https://username:[email protected]/NAME/repo.git 

but it didn't work as my password was containing the field @.

但它不起作用,因为我的密码包含字段@。

I just ran

我刚跑

git credential-osxkeychain erase
host=github.com
protocol=https

command and press enter and it worked perfectly fine. Actually you need to remove the keychain already stored in the osx.

命令并按回车键,它工作得很好。实际上,您需要删除已存储在 osx 中的钥匙串。

回答by Manish Menaria

For me

为了我

git clone https://[email protected]/name/repo.git

worked.

工作。

I think this mainly happens because Private repo can't be accessed directly.

我认为这主要是因为无法直接访问 Private repo。

回答by baitun

I had the same problem (Repository not found) due to the fact that initially I logged in with an incorrect GitHub account. To fix it:

Repository not found由于最初我使用不正确的 GitHub 帐户登录,我遇到了同样的问题 ( )。要解决这个问题:

  1. Open Control Panel from the Start menu.
  2. Select User Accounts.
  3. Select "Manage your credentials" in the left hand menu.
  4. Delete any credentials related to Git or GitHub.
  1. 从开始菜单打开控制面板。
  2. 选择用户帐户。
  3. 在左侧菜单中选择“管理您的凭据”。
  4. 删除与 Git 或 GitHub 相关的任何凭据。

回答by Victor R. Oliveira

What solved my problem, since I was having a "redirect/sign_in URL" or "repository not found" error

是什么解决了我的问题,因为我遇到了“redirect/sign_in URL”或“repository not found”错误

MacOS Users:

macOS 用户:

  1. Open spotlight (Command Space)
  2. Type keychain (Open keychain access.app)
  3. Search for repo domain (GitHub, GitLab, etc)
  4. Delete all keys related to this domain
  5. Try to clone again (with valid credentials)
  1. 打开聚光灯(命令空间)
  2. 键入钥匙串(打开钥匙串 access.app)
  3. 搜索 repo 域(GitHub、GitLab 等)
  4. 删除与此域相关的所有密钥
  5. 再次尝试克隆(使用有效凭据)

Windows users should try similar steps, but Keychain would be Microsoft's Credentials Manager instead or Windows Credentials depending on yours OS version. Make sure to clean both web and windows credentials if that's the case.

Windows 用户应该尝试类似的步骤,但 Keychain 将改为 Microsoft 的凭据管理器或 Windows 凭据,具体取决于您的操作系统版本。如果是这种情况,请确保清理 web 和 windows 凭据。

回答by theking2

If you are on Windows, the repository is private, and different or not longer correct credentials were saved once, you won't have access to the repo. You will get the not found error without hinting in the failed-credential-direction. In order to reset the credentials on Windows, open Control Panel (Win+r control), select User Accounts and Credentials Manager. Locate the git account in Windows credentials (not Web credentials!) and erase this entry.

如果您在 Windows 上,存储库是私有的,并且一次保存了不同或不再正确的凭据,则您将无法访问该存储库。您将在没有提示失败凭据方向的情况下收到未找到错误。要在 Windows 上重置凭据,请打开控制面板(Win+r 控制),选择用户帐户和凭据管理器。在 Windows 凭据(不是 Web 凭据!)中找到 git 帐户并删除此条目。

After that, cloning will pop up a login dialogue and you will be able to set these again.

之后,克隆将弹出一个登录对话框,您将能够再次设置这些。

Tested this with git-bash as shell in VSCode

在 VSCode 中使用 git-bash 作为 shell 对此进行了测试

回答by Nikhil George

On github you can have the main repository and subfolders. Make sure that the URL that you are using is that of the main repository and not that of a folder. The former will succeed and the latter will produce the repository not found error. If you have a doubt you are in a subfolder, navigate up the repository chain till you find a page which actually specified the https URL and use that.

在 github 上,您可以拥有主存储库和子文件夹。确保您使用的 URL 是主存储库的 URL,而不是文件夹的 URL。前者会成功,后者会产生找不到存储库的错误。如果您怀疑自己位于子文件夹中,请向上导航存储库链,直到找到实际指定 https URL 的页面并使用该页面。

回答by Oleg Dater

If you are using two factor authorization (2FA) for your Github account then just use SSH option for cloning your repository:

如果您对 Github 帐户使用双因素授权 (2FA),则只需使用 SSH 选项来克隆您的存储库:

enter image description here

在此处输入图片说明