转自 git clone出现 fatal: unable to access 'https://github.com/...'的解决办法(亲测有效) - 山村码农 - 博客园 (cnblogs.com)

<div id="cnblogs_post_body" class="blogpost-body cnblogs-markdown">
<p>转自:<a href="https://blog.csdn.net/dashi_lu/article/details/89641778" target="_blank" rel="noopener">https://blog.csdn.net/dashi_lu/article/details/89641778</a></p>
<pre highlighted="true"><code class="hljs language-verilog">
如下图所示,当我试图克隆别人的repo时,会发生这样的错误,当我从git:/而不是https:<span class="hljs-comment">//,克隆时,它工作得很好。</span>

&nbsp;发生这种情况是因为代理是在git中配置的。既然它是https代理(而不是http)git <span class="hljs-keyword">config</span> http<span class="hljs-variable">.proxy</span>和git <span class="hljs-keyword">config</span> --<span class="hljs-keyword">global</span> http<span class="hljs-variable">.proxy</span>也无济于事。

解决方案一&nbsp;
<span class="hljs-number">1</span>、看看你的git配置
git <span class="hljs-keyword">config</span> --<span class="hljs-keyword">global</span> -l

如果你没有任何与https代理相关的内容,例如https_proxy = ...问题不在这里。

如果您有与https代理相关的内容,请将其从〜/ <span class="hljs-variable">.gitconfig</span>文件中删除,然后重试。

<span class="hljs-number">2</span>、如果仍然不起作用,请取消设置环境变量&nbsp;
env|grep -i proxy &nbsp;

&nbsp;你应该有一行或几行https_proxy = ...

使用以下内容逐个取消设置:取消设置https_proxy(或HTTPS_PROXY,具体取决于变量的名称)

<span class="hljs-number">3</span>、再次检查环境变量
env|grep -i proxy &nbsp;

如果它没有显示任何你应该是好的。

注意:此解决方案可以应用于http和https代理问题。只是变量名称从https更改为http。

&nbsp;解决方案二
在开启shadowsock的前提下,手动配置git的代理。git客户端输入如下两个命令就可以了。

git <span class="hljs-keyword">config</span> --<span class="hljs-keyword">global</span> http<span class="hljs-variable">.proxy</span> http:<span class="hljs-comment">//127.0.0.1:1080</span>

git <span class="hljs-keyword">config</span> --<span class="hljs-keyword">global</span> https<span class="hljs-variable">.proxy</span> http:<span class="hljs-comment">//127.0.0.1:1080</span>

http:<span class="hljs-comment">//也可以改成sockets5://,但是区别在于:socks5不支持通过pubkey免密登录github,每次提交代码只能输入用户名和密码。http可以支持免密登录。</span>

取消代理:

git <span class="hljs-keyword">config</span> --<span class="hljs-keyword">global</span> --unset http<span class="hljs-variable">.proxy</span>&nbsp;

git <span class="hljs-keyword">config</span> --<span class="hljs-keyword">global</span> --unset https<span class="hljs-variable">.proxy</span>&nbsp;

其实方案一和方案二是同一种方法,不过方案二更加具体一点罢了,大部分问题都可以用方案二解决,当方案二无效时,考虑使用方案一。

</code></pre>

</div>

git clone 问题的更多相关文章

  1. git clone出现的error: The requested URL returned error: 401 Unauthorized

    error: The requested URL returned error: 401 Unauthorized while accessing https://git.oschina.net/.. ...

  2. git clone Linux 源码并切换TAG

    想从github上下载一个特定TAG分支来查看代码,按照先git clone后git checkout的方式,提示说有文件没有提交.因为只查看不编译运行,所以这些关系不大的文件采取删除或者重新命名后提 ...

  3. git clone时,报403错误,完美解决方案

    首先命令行操作结果如下: root@zhiren-PowerEdge-T110-II:/zrun# git clone https://git.coding.net/xxxxxxxx/xxxx.git ...

  4. git clone error: RPC failed; result=22, HTTP code = 502

    http://www.jianshu.com/p/645d3fe4e028 git克隆的工程太大用https的方式会有如下问题 hbl:tmp hubert$ git clone https://gi ...

  5. git clone带用户名和密码的方式

    git clone http://username:password@127.0.0.1/res/res.git

  6. git clone错误

    git clone错误 Initialized empty Git repository in ***/.git/ error: The requested URL returned error: 4 ...

  7. git clone google代码库

    git clone  https://chromium.googlesource.com/chromium/src 发现有将近7G,但是速度太慢,老是失败,提示信息先后是"The remot ...

  8. [译]git clone

    git clone git clone命令copy一个已经存在的Git仓储. git clone有点像svn的checkout, 他的不同之处是这个copy也是一个完整的仓储-它有自己的历史纪录, 能 ...

  9. git clone

    raw text for ssh: git@github.com:TommyU/avbot_config.git git command on linux: git clone git://githu ...

  10. 使用git建立远程仓库,让别人git clone下来

    首先, 如果你的ssh没有安装的话,要安装ssh服务端.ubuntu是很简单 sudo apt-get install openssh-server 1,建立你的git 目录. ourunix@ubu ...

随机推荐

  1. python-你好

    你的程序会读入一个名字,比如John,然后输出"Hello John". 输入格式: 一行文字. 输出格式: 一行文字. 输入样例: Mary Johnson 输出样例: Hell ...

  2. leetcode1753. 移除石子的最大得分

    题目描述: 你正在玩一个单人游戏,面前放置着大小分别为 a​​​​​​.b 和 c​​​​​​ 的 三堆 石子. 每回合你都要从两个 不同的非空堆 中取出一颗石子,并在得分上加 1 分.当存在 两个或 ...

  3. 【uniapp 开发】工具类 -- MathUtil

    获取随机数 /* ** randomWord 产生任意长度随机字母数字组合 ** randomFlag 是否任意长度 min 任意长度最小位[固定位数] max 任意长度最大位 ** ** 生成6-1 ...

  4. numpy教程06---ndarray的进阶操作

    欢迎关注公众号[Python开发实战], 获取更多内容! 工具-numpy numpy是使用Python进行数据科学的基础库.numpy以一个强大的N维数组对象为中心,它还包含有用的线性代数,傅里叶变 ...

  5. spring原始注解

    spring原始注解主要是替代Bean标签的配置 @Component:使用在类上用于实例化Bean @Controller:使用在web层类上用于实例化Bean @Service:使用在servic ...

  6. Java创建boolean型数组

    Java如何声明并初始化一个boolean型的数组? public class Main{ static boolean[] arr1 = new boolean[20]; public static ...

  7. vue build 指定环境

    前言 其实很简单的东西,搜索时很是费劲,特此记录下来.网上有很多资料,但都是五花八门,特此记录 使用 项目根目录中创建环境变量使用文件 .env #所有环境都会加载 .env.development ...

  8. 数据库界的Swagger:一键生成数据库文档!

    对于开发的API文档,我们可以通过Swagger等工具来自动生成了.但是对于数据库表结构的文档呢,在实际开发中在开发前我们一般会先设计好表结构,大家讨论一下, 这个时候就很需要有个数据库表结构的文档, ...

  9. position与float

    position:fixed/absolute和float的关系:元素设置position:absolute / fixed后,float属性是没有效果的.对于position: absolute元素 ...

  10. C++进阶实例2--员工分组

    C++进阶实例2--员工分组 1 #include<iostream> 2 #include<map> 3 #include<vector> 4 #include& ...