Git、Bash、CMD和Powershell的代理配置

PS:

下述方法设置的代理均为临时代理!

Git代理

  • HTTP/HTTPS代理
1
2
3
4
5
6
7
# 设置代理
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080

# 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
  • SOCKS5代理
1
2
3
4
5
6
7
# 设置代理
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1805

# 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy

Bash代理

  • HTTP/HTTPS代理
1
2
3
4
5
6
7
# 设置代理
export http_proxy=http://127.0.0.1:1080
export https_proxy=http://127.0.0.1:1080

# 取消代理
unset http_proxy
unset https_proxy
  • SOCKS代理
1
2
3
4
5
6
7
# 设置代理
export http_proxy="socks5://127.0.0.1:1080"
export https_proxy="socks5://127.0.0.1:1080"

# 取消代理
unset http_proxy
unset https_proxy

PowerShell代理

  • HTTP/HTTPS代理
1
2
3
4
5
6
7
# 设置代理
$env:HTTP_PROXY="http://127.0.0.1:1080"
$env:HTTPS_PROXY="http://127.0.0.1:1080"

# 取消代理
$env:HTTP_PROXY=""
$env:HTTPS_PROXY=""
  • SOCKS代理
1
2
3
4
5
6
$env:HTTP_PROXY="socks5://127.0.0.1:1080"
$env:HTTPS_PROXY="socks5://127.0.0.1:1080"

# 取消代理
$env:HTTP_PROXY=""
$env:HTTPS_PROXY=""

CMD代理

  • HTTP/HTTPS代理
1
2
3
4
5
6
7
# 设置代理
set http_proxy=http://127.0.0.1:1080
set https_proxy=http://127.0.0.1:1080

# 取消代理
set http_proxy=
set https_proxy=
  • SOCKS代理
1
2
3
4
5
6
set http_proxy=socks5://127.0.0.1:1080
set https_proxy=socks5://127.0.0.1:1080

# 取消代理
set http_proxy=
set https_proxy=