1. 给git设置socks5/vmess代理

前提是开启代理服务,可以使用V2rayL: https://github.com/jiangxufeng/v2rayL 和 ghelper

使用 https 的时候,就是使用 https 协议复制仓库的时候

git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'

git config --global http.proxy 'vmess://127.0.0.1:1081'
git config --global https.proxy 'vmess://127.0.0.1:1081'

也可以直接修改用户主目录下的 .gitconfig 文件

[http]
        proxy = socks5://127.0.0.1:1080
[https]
        proxy = socks5://127.0.0.1:1080

[http]
        proxy = vmess://127.0.0.1:1081
[https]
        proxy = vmess://127.0.0.1:1081

取消代理

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

查看已有代理

git config --global -l

在使用 git 开头的路径时,也就是在使用 ssh 通道时

打开用户主目录下的 .ssh/config 文件,添加以下内容

ProxyCommand nc -x localhost:1080 %h %p

ProxyCommand nc -x localhost:1081 %h %p

2. terminal 中设置临时代理

这个操作只对当前窗口有效,关闭当前 terminal 窗口后,将恢复到不是代理的状态

直接执行

export ALL_PROXY=socks5://127.0.0.1:1080

export ALL_PROXY=vmess://127.0.0.1:1081

或者在用户主目录下的 .bash_profile 添加别名,这样以后在使用的时候就可以直接输入 proxy了

alias proxy="export ALL_PROXY=socks5://127.0.0.1:1080"

alias proxy="export ALL_PROXY=vmess://127.0.0.1:1081"

3. 其他方法

使用 https://gitee.com/ 中转

使用 https://g.widora.cn/ 代下

使用 https://d.serctl.com/ 代下