【问题标题】:Git fatal: protocol 'https' is not supportedGit 致命:不支持协议“https”
【发布时间】:2019-05-28 01:21:02
【问题描述】:

我正在浏览 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 地址替换为“。”

【问题讨论】:

  • 你能检查一下复制的文本中是否有任何奇怪的特殊字符。也许尝试输入整个 URL 而不是从 github 复制它。也许还要检查 github.com 是否真的解析为 github,或者是否有东西将其重定向到另一台服务器。
  • 或者您计算机上的某些其他软件损坏了安装的 git(请参阅stackoverflow.com/questions/15553161/…)。在这种情况下,重新安装它可能会解决问题。

标签: git git-bash


【解决方案1】:

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

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

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

或者这个:

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

【讨论】:

  • 抱歉,我不确定为什么是“?”当我从命令行复制时出现。我已经编辑了我的帖子。
  • 帮我试试这些命令,我​​不知道你为什么在github.com/ 后面有一个.,但这是不对的。
  • 谢谢-我重新启动了命令行,由于某种原因现在它可以工作了。我仍然很困惑为什么它一开始就不起作用。
  • 我也解决了打开新命令行的问题。我在安装 Git 时检查了打开 Git Bash 的选项,并第一次使用它来 git clone。这可能是原因。
  • 重启我的终端解决了这个问题
【解决方案2】:

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

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

这是我的历史:

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

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

我用十六进制编辑器将我的 shell 历史文件保存到了一台机器上,并且:

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 96 字符。不知道那是什么。它不是扩展的ASCII(它将是–)吗?当它在剪贴板上时,它几乎隐藏在我粘贴的每个地方。我用这个十六进制值找到的最接近的是https://www.fileformat.info/info/unicode/char/c298/index.htm,但我在任何地方都没有看到 utf 前缀(同样,可能已经丢失了)

这一切都可能具有误导性,因为我丢失了页面/剪贴板并且只使用已保存的 shell 历史文件工作,这很可能丢失了原始错误/恶意注入的数据。

【讨论】:

    【解决方案3】:

    简单的答案就是删除 https

    你的回购。 : (git clone https://........)

    就这样 (git clone ://.......)

    然后再次输入 (git clone https://........)

    【讨论】:

      【解决方案4】:

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

      【讨论】:

        【解决方案5】:

        问题大概是这样的。

        您尝试使用粘贴它

        • CTRL + V

        之前它不起作用,所以你继续用经典粘贴它

        • 右键单击 - 粘贴**。

        遗憾的是,每当您在 terminal 上输入 CTRL + V 时,它都会添加

        • 一个隐藏 ^?

        (至少在我的机器上是这样编码的)。

        你只在你之后出现的角色

        • 退格

        (继续在 git bash 上尝试一下)。

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

        这是无效的。

        【讨论】:

        • 但是为什么会这样呢?
        • 成功了,谢谢!我用鼠标右键粘贴了它。然后,我将光标放在“https”中间并多次按下退格键
        • 很高兴想到这可能会发生在其他人身上并且毫不犹豫地发布它
        • 您先生,是救生员!这太荒谬了……但感谢您的发帖!像魅力一样工作。
        • 在 Windows PC 上工作时遇到此问题。谢谢。
        【解决方案6】:

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

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

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

        【讨论】:

          【解决方案7】:

          我遇到了同样的问题,我所做的只是重新启动命令行,然后使用命令 '' cd documents '' 导航到文档文件夹而不是用户文件夹。这应该就是所有需要的了。还要确保链接正确。

          【讨论】:

            【解决方案8】:

            您可能正在使用未登录 git hub 的 Windows 或 Linux 计算机,因此未验证证书。从您收到错误登录的系统使用凭据登录到 GitHub,然后尝试使用它会起作用的命令。

            【讨论】:

              【解决方案9】:

              使用 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.
              

              【讨论】:

                【解决方案10】:

                问题

                git 克隆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.
                

                【讨论】:

                  【解决方案11】:

                  复制到普通记事本(git clone https://github.com/./Spoon-Knife.git)并粘贴到cmd中。

                  【讨论】:

                    【解决方案12】:

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

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

                    【讨论】:

                      【解决方案13】:

                      你试过这个:

                      Ctrl + V

                      只需右键点击粘贴

                      【讨论】:

                        【解决方案14】:

                        当我试图变得聪明并自己从 repo 的 URL 中提取克隆 URL 时,我遇到了这个错误。我做错了。我在做:

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

                        我必须做的:

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

                        我犯了 3 个错误:

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

                        【讨论】:

                          【解决方案15】:

                          即使在most upvoted answer. 修复后,此问题仍然存在

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

                          但是如果您在 Windows 或 Google 搜索栏中复制该消息,您会发现实际消息是 fatal: protocol '##https' is not supported,其中“#”代表 this character。如您所见,这两个字符并没有被删除。

                          我正在开发 IntelliJ IDEA Community Edition 2019.2.3,以下修复涉及此工具,答案是这 2 个字符仍然存在并且需要被从链接中删除

                          IntelliJ 修复

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

                          现在它会打开一些链接

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

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

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

                          【讨论】:

                            【解决方案16】:

                            只需添加这个git config --global http.sslVerify false ,这样它就不会检查证书。

                            【讨论】:

                              【解决方案17】:

                              如果您使用的是 Git Bash:

                              不要通过按 Ctrl + V 来粘贴链接。
                              您只需键入 git clone 右键单击然后粘贴

                              【讨论】:

                                【解决方案18】:

                                我在尝试通过 Visual Studio 进行克隆时遇到此错误。当我在 PowerShell 中做同样的事情时,它工作得很好。

                                【讨论】:

                                  【解决方案19】:

                                  我收到了一个看起来与此非常相似的错误,因为我在 URL 周围加上了单引号:

                                  致命:不支持协议“https”

                                  从 URL 中删除单引号解决了问题。

                                  【讨论】:

                                  • 这帮助我解决了这个问题。谢谢
                                  【解决方案20】:

                                  如果您使用 Visual Studio 或 Git GUI 进行克隆,则需要删除“git clone”命令。只需要地址。

                                  【讨论】:

                                    猜你喜欢
                                    • 2019-08-16
                                    • 1970-01-01
                                    • 2020-01-22
                                    • 2015-03-16
                                    • 2014-03-05
                                    • 2013-03-11
                                    • 2016-12-12
                                    • 2019-08-06
                                    • 2012-03-24
                                    相关资源
                                    最近更新 更多