Git代理设置(包括账号密码)--公司内网访问常用

用Git去Clone项目的时候报错:Failed to connect to github.com/gitee.com port 443: Timed out

如果不是你的网络错误,那一般就是代理设置错误了。特别是在公司内网,需要代理登陆外网时。

1.开启全局的git代理

因为我们公司代理是需要ip,端口,账号,密码的,所以在网上找资料不太好找,大部分的资料都是不需要账号密码的。好不容易找到一个照着配,[link]https://www.jianshu.com/p/b3154ae86fe2 ,作者写的很认真,很给启发,但是却错了。

原代码是这样的:

git config --global http.proxy http://wangrui:P!1234@http://proxy.pjs.com:9090
git config --global https.proxy https://wangrui:P!1234@https://proxy.pjs.com:9090

实际上应该是这样的:

git config --global http.proxy http://wangrui:[email protected]:9090
git config --global https.proxy https://wangrui:[email protected]:9090

然后还有个问题,上述的密码中有特殊符号!,如果你直接运行,git会报错,需要encode转义一下。

最终正确的应该如下:

git config --global http.proxy http://wangrui137:P%[email protected]:9090

2.关闭代理

git config --global (或 --local) --unset https.proxy
git config --global --unset http.proxy 

3.查看是否生效

git config --get --global http.proxy
发布了23 篇原创文章 · 获赞 0 · 访问量 2万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章