有些时候由于连不上git服务器而我们又需要推送代码,这时就需要设定git代理服务器。
1,http和https代理
如果说使用的是项目http或者https地址,就配置http与https代理即可,输入以下命令:
git config --global http.proxy "socks5://地址:端口"
git config --global https.proxy "socks5://地址:端口"
例如设定本地代理:
git config --global http.proxy "socks5://127.0.0.1:1080"
git config --global https.proxy "socks5://127.0.0.1:1080"
这样使用git clone/push/pull所有http或者https地址项目都会走代理。
还可以使用下面命令取消代理设置:
git config --global --unset http.proxy
git config --global --unset https.proxy
2,ssh代理设定
如果说项目使用的ssh地址,那么就需要配置ssh代理。
我们需要编辑ssh的配置文件,位于用户文件夹下的.ssh文件夹下。
Windows ssh配置文件路径:C:\Users\你的用户名\.ssh\config
Linux ssh配置文件路径: