无法使用 git clone git://... 克隆 repo - 可以使用 git clone http://

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19683557/
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-10 17:13:46  来源:igfitidea点击:

Can't clone repo using git clone git://... - ok with git clone http://

githttpgit-clone

提问by Tony B

Git newbie here. I'm setting up git on a new Ubuntu VM and trying to clone some repos. The clone works for the following command:

Git新手在这里。我正在一个新的 Ubuntu VM 上设置 git 并尝试克隆一些存储库。克隆适用于以下命令:

git clone http://github.com/organisation_name/repo_name

(after prompt for username/password), but fails for

(提示输入用户名/密码后),但失败

git clone git://github.com/organisation_name/repo_name

and also

并且

git clone git://github.com/organisation_name/repo_name.git

with the same error message:

具有相同的错误消息:

Cloning into 'repo_name'...
fatal: remote error:
Repository not found

Of course the obvious answer is "use the httpmethod", but I'm trying to understand why one works and the other doesn't. Any suggestions? (also is there any difference when using the .gitextension on the repo name btw?)

当然,显而易见的答案是“使用http方法”,但我试图理解为什么一个有效而另一个无效。有什么建议?(.git顺便说一句,在 repo 名称上使用扩展名时也有什么区别吗?)

Thanks!

谢谢!

采纳答案by u1860929

Well, I think you are using the wrong url in your second case

好吧,我认为您在第二种情况下使用了错误的网址

Try this instead

试试这个

git clone [email protected]:organisation_name/repo_name.git

The difference is the :in the url when using git@vs the /you are currently using, and the extra .gitat the end.

不同之处在于使用:时的 urlgit@/您当前使用的 url ,以及.git末尾的额外内容。

This should be the same url if you go to github and select the ssh url for cloning (and not the https one selected by default)

如果您转到 github 并选择用于克隆的 ssh 网址(而不是默认选择的 https 网址),这应该是相同的网址

回答by Srdjan Grubor

If this is a private repository, you need to add your machine's ssh public key to you account under https://github.com/settings/sshotherwise you will get the exact error you are listing here.

如果这是一个私有存储库,您需要将您机器的 ssh 公钥添加到您在https://github.com/settings/ssh下的帐户,否则您将得到您在此处列出的确切错误。

回答by wasatchwizard

I just wanted to throw out there that my problem was the network. All of my settings were good. I was told the network didn't filter or block ports or anything, but after trying everything I could think of and everything I could find online; I finally tethered my laptop to my mobile phone and everything started working just fine.

我只是想说我的问题是网络。我所有的设置都很好。有人告诉我网络没有过滤或阻止端口或任何东西,但是在尝试了我能想到的所有东西以及我可以在网上找到的所有东西之后;我终于把我的笔记本电脑拴在我的手机上,一切都开始正常工作了。

回答by Manasvee Kumar

Query: why HTTPS URL works and SSH URL doesn't?
The purposeof SSH URLs is to provide access to a Git repository via SSH, a secureprotocol. To use these URLs, you must generate an SSH keypair on your computer and add the public key to your GitHub account.

查询:为什么 HTTPS URL 有效而 SSH URL 无效?SSH URL
目的是通过 SSH(一种安全协议)提供对 Git 存储库的访问。要使用这些 URL,您必须在您的计算机上生成一个 SSH 密钥对并将公钥添加到您的 GitHub 帐户。