终端设置代理

发布于:2023-05-14 ⋅ 阅读:(558) ⋅ 点赞:(0)

起因

由于之前git clone或者类似操作经常出现问题,但我本身开了代理的,所以不知道出了什么问题,后面才知道需要另外设置代理,这里总结一下不同平台终端开启代理方式。

image-20230514151726235

git bash

设置代理,注意端口号是你代理软件的端口

git config --global http.proxy http://127.0.0.1:9080
git config --global https.proxy https://127.0.0.1:9080

如果是其他协议,直接更改后面的值即可http.proxyhttps.proxy

重置代理

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

Windows powershell

$env:HTTP_PROXY="http://127.0.0.1:9080"
$env:HTTPS_PROXY="https://127.0.0.1:9080" 

Windows CMD

set http_proxy=http://127.0.0.1:9080
set https_proxy=http://127.0.0.1:9080

MAC iterm2

export http_proxy=http://127.0.0.1:9080
export https_proxy=$http_proxy

重置代理

unset http_proxy https_proxy

本文由mdnice多平台发布