背景需求
github 不少仓库被墙,不管是拉取代码还是推送代码都不能正常使用,应该怎么解决呢?
代理配置
为了减少对其他仓库的影响,需求应该还包括只对 github.com
仓库配置代理,有以下几种方法:
- 配置一次性代理,只对当前命令生效
# git clone 一次性代理
git clone -c http.proxy="http://127.0.0.1:1087" https://github.com/
- 设置全局代理,对git的所有命令生效
# 全局设置代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
- 通过文件配置全局代理
在 .ssh/config 文件中添加如下内容,如果windows下没有这个文件需要新建一下
Host github.com
User yuc
ProxyCommand connect -S 127.0.0.1:3128 %h %p
评论