Git问题:Git clone 时遇到fatal: protocol 'https' is not supported问题解决方案

在 Git Bash 里执行 clone 命令时,有时候会莫名其妙报错protocol ''https'' is not supported,这是为什么呢?

本篇文章带你理解这个报错的由来,以及对应的解决方式。

一、问题来因

今天在整合项目时需要将码云上的仓库clone下来,在 Git Bash 里执行 clone命令报错protocol ''https'' is not supported,经过一番查找,找到了原因,分享给大家,其实也是我们常犯的一个错误。

二、寻找解决方案

开始在CSDN上找各种解决办法,并没有任何成果,遇到的问题情况和我都不一样。

我一直秉承的思想是问题不能只有解决了才行,我们应该去找到问题产生的原因。

最后在stackoverflow上找到了解决方案和原因,其中是这么写到的:

You tried to paste it using

  • CTRL +V

before and it didn’t work so you went ahead and pasted it with classic

  • Right Click - Paste**.

Sadly whenever you enter CTRL +V on terminal it adds

  • a hidden ^?

(at least on my machine it encoded like that).

the character that you only appears after you

  • backspace

(go ahead an try it on git bash).

So your link becomes ^?https://...

which is invalid.

什么意思呢?就是说我们在粘贴地址时使用了 CTRL +V, 在Git Bash中没有效果,然后我们就会使用右键菜单中的粘贴,但是不幸的是,使用 CTRL +V会在Git Bash 中添加一个隐藏的符号 ^?

当你在粘贴仓库链接时使用了CTRL +V

在GIt Bash 中你的克隆语句可能显示是这样正常的:

git clone https://gitee.com/qianfanguojin/homework_1.git

但真实语句其实是这样的:

git clone ^?https://gitee.com/qianfanguojin/homework_1.git

链接前面多了符号,协议变成了^https,肯定不能克隆成功,提示协议不支持。

三、问题解决办法

解决问题的办法也很简单,将使用了CTRL +V的克隆语句删除重新编写,但是记得粘贴链接时不要使用CTRL +V即可。

这个问题也提醒我们不要在 命令行中乱用 CTRL +V或是CTRL +C这类快捷键,可能会出现莫名其妙的BUG。

四、参考链接

https://stackoverflow.com/questions/53988638/git-fatal-protocol-https-is-not-supported