致命的Git:不支持协议'https'


188

我正在阅读Github的分叉指南:https : //guides.github.com/activities/forking/ ,我正在尝试将存储库克隆到我的计算机上。但是,运行命令:

$ git clone https://github.com/./Spoon-Knife.git
Cloning into 'Spoon-Knife'...
fatal: protocol 'https' is not supported

还尝试使用SSH:

$ git clone git@github.com:./Spoon-Knife.git
Cloning into 'Spoon-Knife'...
Warning: Permanently added the RSA host key for IP address '.' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我需要在计算机上更改某些配置设置,还是GitHub有问题?

编辑:我已经用“。”替换了我的用户名和IP地址。


2
您能检查复制的文本中是否有任何奇怪的特殊字符。也许尝试键入整个URL,而不是从github复制它。也许还要检查github.com是否确实解析为github或是否有将其重定向到另一台服务器的内容。
lw1.at

1
或者您计算机上的某些其他软件损坏了已安装的git(请参阅stackoverflow.com/questions/15553161/…)。在这种情况下,重新安装它可能会解决此问题。
lw1.at

2
出于某种原因,我重新启动了命令行,现在可以正常使用了
Hank Lin

Answers:


556

问题可能是这样。

您尝试使用粘贴

  • CTRL + V

之前,它没有用,所以您继续将其粘贴到经典

  • Right Click -粘贴**。

可悲的是,每当您CTRL终端上输入+ V时,它都会添加

  • 一个隐藏的 ^?

(至少在我的计算机上,它的编码方式是这样的)。

您仅在您之后出现的字符

  • backspace

(继续尝试git bash)。

所以你的链接变成 ^?https://...

这是无效的。


24
这是解决方案!
devman

27
不敢相信我们必须处理这样的事情。看不见的字符使您的工作持续更长的时间。谢谢!为我工作。
永恒的

3
谢谢!我删除并重写了https的h,它可以正常工作!
沃尔特·塞哈斯

2
就是这样 我正在使用MINGW。我在粘贴之前尝试了ctrl + v和shift + ctrl + v,但操作失败,但是在再次尝试使用GUI粘贴选项后,它成功克隆了我的存储库。谢谢!
弗兰克,

2
我想嫁给这个答案<3
克鲁斯

22

编辑: 通过启动一个新的终端会话,解决了这个特定的用户问题。

?不支持协议(https)之前的A。你要这个:

git clone git@github.com:octocat/Spoon-Knife.git

或这个:

git clone https://github.com/octocat/Spoon-Knife.git

选择要克隆的位置


对不起,我不确定为什么是“?” 从命令行复制时出现。我已经编辑了我的帖子。
Hank Lin

为我尝试这些命令中的任何一个,我不知道为什么您之后会有一个.github.com/但这是不正确的。
TomDunning

2
谢谢-我重新启动了命令行,由于某种原因,它现在可以工作了。我仍然很困惑为什么它从一开始就不起作用。
Hank Lin

1
我还解决了打开新命令行的问题。我在安装Git时检查了打开Git Bash的选项,并在第一次使用git clone了。这可能是原因。
独立的拉哥尼亚人

2
重新启动终端可以解决此问题
-Elkas,


8

只需对URL使用双引号,例如: git clone "https://yourRepoUrl"

(它以某种方式显示您在开始时使用了两个引号,不知道为什么)。

我遇到了相同的错误=> fatal: protocol ''https' is not supported(您可以在https上看到2个引号)。


4

发生了一些可疑的事情。可能是不一致的github错误(A / B测试?)

我在Windows10上,使用Firefox。我刚刚复制了一个结帐网址,并得到了一个额外的字符。但是只有第一次。第二次不在那里。我必须查看我的历史记录文件才能看到它!

这是我的历史:

git clone --recursive https://github.com/amzeratul/halley-template
git clone --recursive http://github.com/amzeratul/halley-template
git clone --recursive github.com/amzeratul/halley-template
git clone --recursive https://github.com/amzeratul/halley-template

history命令不显示多余的字符。就像当我将其复制粘贴到终端中时未渲染一样。您可以看到我如何尝试删除“ s”,然后删除整个协议吗?当退格键移动的字符数比我预期的少一个时,我才被触发进一步调查!

我将外壳历史记录文件保存到具有十六进制编辑器的计算机上,并且:

00000000  xx xx xx xx xx xx xx 0a  67 69 74 20 63 6c 6f 6e  |xxxxxxx.git clon|
00000010  65 20 2d 2d 72 65 63 75  72 73 69 76 65 20 c2 96  |e --recursive ..|
00000020  68 74 74 70 73 3a 2f 2f  67 69 74 68 75 62 2e 63  |https://github.c|
00000030  6f 6d 2f 61 6d 7a 65 72  61 74 75 6c 2f 68 61 6c  |om/amzeratul/hal|
00000040  6c 65 79 2d 74 65 6d 70  6c 61 74 65 0a 67 69 74  |ley-template.git|
00000050  20 2d 2d 68 65 6c 70 0a  67 69 74 20 75 70 64 61  | --help.git upda|
00000060  74 65 2d 67 69 74 2d 66  6f 72 2d 77 69 6e 64 6f  |te-git-for-windo|
00000070  77 73 0a 67 69 74 20 63  6c 6f 6e 65 20 2d 2d 72  |ws.git clone --r|
00000080  65 63 75 72 73 69 76 65  20 c2 96 68 74 74 70 73  |ecursive ..https|
00000090  3a 2f 2f 67 69 74 68 75  62 2e 63 6f 6d 2f 61 6d  |://github.com/am|
000000a0  7a 65 72 61 74 75 6c 2f  68 61 6c 6c 65 79 2d 74  |zeratul/halley-t|
000000b0  65 6d 70 6c 61 74 65 0a  63 75 72 6c 20 2d 2d 76  |emplate.curl --v|
000000c0  65 72 73 69 6f 6e 0a 63  64 20 63 6f 64 65 0a 67  |ersion.cd code.g|
000000d0  69 74 20 63 6c 6f 6e 65  20 2d 2d 72 65 63 75 72  |it clone --recur|
000000e0  73 69 76 65 20 c2 96 68  74 74 70 73 3a 2f 2f 67  |sive ..https://g|
000000f0  69 74 68 75 62 2e 63 6f  6d 2f 61 6d 7a 65 72 61  |ithub.com/amzera|
00000100  74 75 6c 2f 68 61 6c 6c  65 79 2d 74 65 6d 70 6c  |tul/halley-templ|
00000110  61 74 65 0a 67 69 74 20  63 6c 6f 6e 65 20 2d 2d  |ate.git clone --|
00000120  72 65 63 75 72 73 69 76  65 20 c2 96 68 74 74 70  |recursive ..http|
00000130  3a 2f 2f 67 69 74 68 75  62 2e 63 6f 6d 2f 61 6d  |://github.com/am|
00000140  7a 65 72 61 74 75 6c 2f  68 61 6c 6c 65 79 2d 74  |zeratul/halley-t|
00000150  65 6d 70 6c 61 74 65 0a  67 69 74 20 63 6c 6f 6e  |emplate.git clon|
00000160  65 20 2d 2d 72 65 63 75  72 73 69 76 65 20 67 69  |e --recursive gi|
00000170  74 68 75 62 2e 63 6f 6d  2f 61 6d 7a 65 72 61 74  |thub.com/amzerat|
00000180  75 6c 2f 68 61 6c 6c 65  79 2d 74 65 6d 70 6c 61  |ul/halley-templa|
00000190  74 65 0a 67 69 74 20 63  6c 6f 6e 65 20 2d 2d 72  |te.git clone --r|
000001a0  65 63 75 72 73 69 76 65  20 68 74 74 70 73 3a 2f  |ecursive https:/|
000001b0  2f 67 69 74 68 75 62 2e  63 6f 6d 2f 61 6d 7a 65  |/github.com/amze|
000001c0  72 61 74 75 6c 2f 68 61  6c 6c 65 79 2d 74 65 6d  |ratul/halley-tem|
000001d0  70 6c 61 74 65 0a                                 |plate.|
000001d6

c2 96URL之前插入了ia char。不知道那是什么。它是否不是扩展的ASCII(应为ASCII –),并且在剪贴板上粘贴的几乎每个位置都被隐藏了。我发现与此十六进制值最接近的是https://www.fileformat.info/info/unicode/char/c298/index.htm但我在任何地方都看不到utf前缀(再次,可能已经丢失了) )

由于我丢失了页面/剪贴板,并且只能从保存的外壳历史记录文件进行工作,因此所有这些都可能会引起误解,这很可能会丢失原始错误/恶意注入中的数据。


2

问题

git clone https://github.com/rojarfast1991/TestGit.git 致命:不支持协议“ https”

解:

脚步:

(1):-打开新终端并克隆git存储库

git clone https://github.com/rojarfast1991/TestGit.git

(2)将打开自动git登录提示,并要求您输入用户凭据。

用户名:-xxxxxxx

密码:-xxxxxxx

最后,克隆将开始...

git clone https://github.com/rojarfast1991/TestGit.git
Cloning into 'TestGit'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.

1

在Windows 10上全新安装git并首次运行后,我遇到了相同的问题。重新启动bash窗口解决了该问题。


1

使用http代替https ; 它将给出警告消息并重定向到https,将其克隆而没有任何问题。

$ git clone http://github.com/karthikeyana/currency-note-classifier-counter.git
Cloning into 'currency-note-classifier-counter'...
warning: redirecting to https://github.com/karthikeyana/currency-note-classifier-counter.git
remote: Enumerating objects: 533, done.
remote: Total 533 (delta 0), reused 0 (delta 0), pack-reused 533
Receiving objects: 100% (533/533), 608.96 KiB | 29.00 KiB/s, done.
Resolving deltas: 100% (295/295), done.

0

我遇到了同样的问题,我所要做的就是重新启动命令行,然后使用“ cd files”命令导航到document文件夹而不是user文件夹。那应该是所有这些。还要确保链接正确。


0

您可能正在使用未登录git hub的Windows或linux计算机,因此未验证证书。从出现错误的系统使用凭据登录到github,然后尝试使用将起作用的命令。祝好运



0

我尝试了很多方法来解决这个问题。但是我一次又一次失败。然后我这样做:

打开Git Bash>转到directory> 粘贴git clone https://shahadat@bitbucket.org/*******.git然后将显示命令提示符以提供登录凭据。提供凭据并克隆您的项目。



0

当我尝试变得聪明并自己从存储库的URL中提取克隆URL时,出现了此错误。我做错了。我在做:

git@https://github.company.com/Project/Core-iOS

我必须做的:

git@github.company.com:Project/Core-iOS.git

我有3个错误:

  • 没有 https://
  • .com我需要:而不是/
  • 最后我需要一个 .git

0

即使在大多数支持答案的修复程序中,此问题仍然存在

更具体地说,我粘贴的链接中没有“ Ctrl + v”,但仍然给出了fatal: protocol 'https' is not supported

但是,如果您在Windows或Google搜索栏中复制该消息,则会得到实际的消息fatal: protocol '##https' is not supported,其中“#”代表该字符。如您所见,这2个字符尚未删除。

我正在使用IntelliJ IDEA Community Edition 2019.2.3,以下修复程序涉及此工具,答案是那两个字符仍然存在,需要从链接中删除

IntelliJ修复

转到顶部栏,选择VCS-> Git-> Remotes ...,然后单击。

现在它将打开一些链接

在此处输入图片说明

您可以看到这2个无法识别的字符。我们必须删除它们。单击“编辑”图标并删除这两个字符,或者您可以删除链接并添加一个新的字符。

确保项目文件夹中有“ .git”文件夹

在此处输入图片说明

现在它应该像这样。单击“确定”,现在您可以将文件推送到git存储库。

在此处输入图片说明

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.