Git设置代理,带用户名与密码

编程入门 行业动态 更新时间:2024-10-25 04:19:01

Git设置代理,带<a href=https://www.elefans.com/category/jswz/34/1770444.html style=用户名与密码"/>

Git设置代理,带用户名与密码

公司软件需要设置代理才能连接外网。

蓝色部分:用户名;

绿色部分:密码;

紫色部分:代理IP与端口,如:192.10.10.10:8080

测试端口语句:

 

参考链接及内容1:

Git的代理设置也非常简单,一句话就搞定了:

git config --global http.proxy http://xxx:8080
git config --global https.proxy https://xxx:8080

如果需要用户名密码的话,则设置:

git config --global http.proxy http://user:password@:8080

其中 user 和 password 分别为你的用户名和密码。
设置完成后,可以通过如下命令来查看设置是否生效:

git config --get --global http.proxy

 

如果某一天你不喜欢她了,需要删除代理设置,那么可以使用:

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

来删除设置。
作者:yujiawei007
链接:
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

 

参考链接及内容2:

Failed to connect to github port 443: Timed out

  • 用Git去Clone项目的时候报错:Failed to connect to github/gitee port 443: Timed out
    • 1.开启全局的git代理
    • 2.关闭代理
    • 3.查看是否生效

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

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

1.开启全局的git代理

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

原代码是这样的:

1|git config --global http.proxy http://wangrui:P!1234@:9090
2|git config --global https.proxy https://wangrui:P!1234@:9090
  •  

实际上应该是这样的:

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

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

最终正确的应该如下:

git config --global http.proxy http://wangrui137:P%211234@proxy.pjs:9090
  • 1

2.关闭代理

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

3.查看是否生效

git config --get --global http.proxy

更多推荐

Git设置代理,带用户名与密码

本文发布于:2024-02-12 05:02:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1686189.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户名   密码   Git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!