网络代理条件下配置git

网络代理条件下配置git

当网络使用了代理,在使用git时出现如下情况:

git clone https://github.com/golang/lint.git
Cloning into 'lint'...
fatal: unable to access 'https://github.com/golang/lint.git/': Could not resolve host: github.com

使用git的bash去ping其他网站,发现ping不通,考虑可能是因为自己的主机配置了代理服务器,从而对尝试为git bash设置代理。

配置如下:

  • HTTPS:
    • git config --global http.proxy "http://ip:port"
  • HTTP:
    • git config --global https.proxy "https://ip:port"

然后使用命令查看是否配置成功

git config --get http.proxy
git config --get https.proxy

此时应该返回你所使用的代理服务器的IP和端口

再次使用 git clone命令发现成功。

原文地址:https://www.cnblogs.com/jmtang/p/13177317.html