终端+git设置代理联网
May 30, 2018
天朝的网络环境对技术人员实在是不友好,还好ShadowsocksX-NG已支持sock5,http两种代理协议。
设置终端代理
- 在 .bashrc 或 .zshrc 中设置如下内容
1
2
3
4
5
6
7
8
9
10#sock代理
alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1080"
alias unsetproxy="unset ALL_PROXY"
#http代理
alias setproxy="export ALL_PROXY=http://127.0.0.1:8035"
alias unsetproxy="unset ALL_PROXY"
#测试
curl ip.cn
设置git代理
- 可以编辑~/.gitconfig或者直接执行下面命令
1
2
3
4
5
6
7
8
9
10
11#sock代理
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
#http代理
git config --global http.proxy "http://127.0.0.1:8035"
git config --global https.proxy "http://127.0.0.1:8035"
#取消设置
git config --global --unset http.proxy
git config --global --unset https.proxy