zl程序教程

您现在的位置是:首页 >  云平台

当前栏目

git代理设置与取消

代理Git 设置 取消
2023-09-11 14:22:07 时间

0x00 前言

  1. 国外的git代码下载速度很慢,怎么办?
  2. google的代码无法下载怎么办?

解决方法简单暴力,前提就是手里要有一个国外的代理,可以翻墙下载东西。

0x01 设置HTTP代理

设置全局代理模式,这里只设置了http,下载aosp项目足够用了,至于https代理没有研究

git config --global http.proxy http://127.0.0.1:8080

设置完后,在 ~/.gitconfig 这个文件中会找到对应配置

[http]
        proxy = http://127.0.0.1:8080

不使用命令的话,直接创建并修改这个文件也可以。

0x02 取消代理

git config --global --unset http.proxy

0x03 HTTPS设置与取消

跟HTTP代理是一样的,只不过config对于的key是https.proxy

#设置https代理
git config --global https.proxy http://127.0.0.1:8080
#取消https代理
git config --global --unset https.proxy

当然,如果用socks协议,只需要把http://或者https://替换为socks5://即可

0x04 参考文献

https://stackoverflow.com/questions/128035/how-do-i-pull-from-a-git-repository-through-an-http-proxy