CodeBlog

Windows git和cmd代理设置

设置Git代理

http代理:

临时代理:
export http_proxy=http://127.0.0.1:7777
export https_proxy=http://127.0.0.1:7777
永久代理:


命令方式:
git config --global http.proxy http://127.0.0.1:50015
git config --global https.proxy http://127.0.0.1:50015
修改配置文件方式
进入用户名根路径,找到 .gitconfig 文件,修改(地址和端口换成自己的)为:

[http]
proxy = http://127.0.0.1:50015
[https]
proxy = http://127.0.0.1:50015
查看http (s)代理情况:
git config --get --global http.proxy
git config --get --global https.proxy

永久代理 - SOCKS5 代理设置

命令方式:
git config --global http.proxy socks5://127.0.0.1:50014
git config --global https.proxy socks5://127.0.0.1:50014
修改配置文件方式:
进入用户名根路径,找到 .gitconfig 文件,修改(地址和端口换成自己的)为:

[http]
proxy = socks5://127.0.0.1:50015
[https]
proxy = socks5://127.0.0.1:50015
查看SOCKS5 代理情况:
git config --get --global http.proxy
git config --get --global https.proxy
git config --get --global http.proxy socks5
git config --get --global https.proxy socks5

git取消http(s)或socks代理:

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

例:

git config --global --unset http.proxy
git config --global --unset https.proxy

----------------------------------------------------------------------------------------------------------------------------------------

设置CMD代理

CMD - http代理

cmd临时代理方案(cmd窗口关闭,则代理失效)
set http_proxy=http://127.0.0.1:50015
set https_proxy=http://127.0.0.1:50015
$env:http_proxy="http://127.0.0.1:1080"
$env:https_proxy="http://127.0.0.1:1080"
cmd永久代理方案
 netsh winhttp import proxy source=ie

CMD - SOCKS5 代理设置

set http_proxy=socks5://127.0.0.1:50014
set https_proxy=socks5://127.0.0.1:50014

CMD(服务器)针对性代理,绕过本地请求(修改为自己的代理地址和端口)


http:
        netsh winhttp set proxy proxy-server="http=192.168.17.100:50015" bypass-list="localhost"
https:
        netsh winhttp set proxy proxy-server="http=192.168.17.100:50015" bypass-list="localhost"
socks:
        netsh winhttp set proxy proxy-server="socks=192.168.17.100:50015" bypass-list="localhost"
CMD查看代理情况:
netsh winhttp show proxy
CMD取消代理:
netsh winhttp reset proxy



作者:Avey777

链接:https://www.jianshu.com/p/b9047a59ffc9

来源:简书

著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

发布:2021-09-06 19:45:04

修改:2021-12-22 11:16:44

鲁ICP备17013715号 min-Blog powered by ZPHP-MIN