git 设置本地代理访问外网

git设置本地代理访问外网

在局域网工作时,上网一般会配置http代理服务器,甚至有可能需要用户名、密码。

在这种情况下,我们在命令行中使用git会遇到如何设置代理的问题。如下示例,供参考。

git 设置 http代理:

git config --global http.proxy 'http://user_name:password@http_proxy_ip:port'
# 例如:
git config --global http.proxy 'http://zhangsan:[email protected]:8080'

设置好后,即可正常访问github。

如何取消代理:

git config --global --unset http.proxy

如何查看当前设置的代理:

git config --global --get http.proxy

除此之外,git 还可以设置 https.proxy,方法类似于http.proxy。

另外对于socket代理,也可以设置代理,参见如下示例(对此尚未验证)。
git config --global http.proxy 'socks5://127.0.0.1:1080'

参考资料

CMD 和 Git 中的代理设置
git设置代理、记住密码

猜你喜欢

转载自blog.csdn.net/pierre_/article/details/89136450