Git设置代理

有时会国内会因为github克隆速度非常慢,中途各种错误断开造成克隆项目失败,可以尝试设置代理解决
设置代理

1.http || https协议

//设置全局代理
//http
git config --global https.proxy http://127.0.0.1:1080
//https
git config --global https.proxy https://127.0.0.1:1080
//使用socks5代理的 例如ss,ssr 1080是windows下ss的默认代理端口,mac下不同,或者有自定义的,根据自己的改
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080

//只对github.com使用代理,其他仓库不走代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
git config --global https.https://github.com.proxy socks5://127.0.0.1:1080
//取消github代理
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy

//取消全局代理
git config --global --unset http.proxy
git config --global --unset https.proxy

2.SSH协议

//对于使用git@协议的,可以配置socks5代理
//在~/.ssh/config 文件后面添加几行,没有可以新建一个
//socks5
Host github.com
User git
ProxyCommand connect -S 127.0.0.1:1080 %h %p

//http || https
Host github.com
User git
ProxyCommand connect -H 127.0.0.1:1080 %h %p
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • GIt需要设置代理,才能正常访问github 等网站 设置如下(可复制): git config --global...
    陈树树go阅读 44,342评论 0 10
  • 设置代理: 全局代理 git config --global http.proxy 127.0.0.1:1087 ...
    LOok_阳阳阅读 14,413评论 4 7
  • 这几天在使用git拉取或者pull代码的时候超级慢,先后试了好几种办法,删除远程仓库地址重新设置,重新设置conf...
    mills_han阅读 20,320评论 0 6
  • 设置ss git config --global http.proxy 'socks5://127.0.0.1:1...
    且须文雅阅读 2,040评论 2 28
  • 二零一八年年刚过,初四,假期未过,便迎来一场同学聚会, 接到通知是昨天下午,一个在许昌书店的朋友的电话,地扯是许昌...
    姚红军阅读 258评论 2 1