首页 > Web开发 > 详细

git配置http代理

时间:2020-09-07 08:12:20      阅读:73      评论:0      收藏:0      [点我收藏+]

git配置http代理

经常遇到克隆 github 慢的问题,这里记录一下几种配置 git 代理的方法,解决 clone github 过慢。

目录

git配置代理

主要使用 git config 命令

git单独配置github代理

1.https 访问

仅为 github 设置 http 或 socks5 代理

# 设置 http 代理
git config --global http.https://github.com.proxy http://127.0.0.1:1080

# 设置 socks5 代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

# 取消代理
git config --global --unset http.https://github.com.proxy

设置完成后, ~/.gitconfig文件中会增加以下条目:

[http "https://github.com"]
    proxy = socks5://127.0.0.1:1080

2.ssh协议访问

需要修改 ~/.ssh/config 文件, 没有的话新建一个. 同样仅为 github.com 设置代理,代理必须是 socks5 类型:

Host github.com
    User git
    ProxyCommand nc -v -x 127.0.0.1:1089 %h %p

git配置全局代理

# 设置代理
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080

# 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy

配置终端环境变量

主要是 http_proxy、https_proxy 两个环境变量;打开终端,输入如下命令:

export http_proxy=http://127.0.0.1:1080
export https_proxy=http://127.0.0.1:1080

git配置http代理

原文:https://www.cnblogs.com/trrtly/p/13624518.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!