最近更新于 2023-12-22 19:38

相关:

1 http

git config --global http.proxy http://[IP]:[Port]

比如这里我是本机 v2rayN 开的服务,默认 http 端口为 10809

file

git config --global http.proxy http://127.0.0.1:10809

2 socks5

git config --global http.proxy socks5://[IP]:[Port]

比如这里我是本机 v2rayN 开的服务,默认 socks5 端口为 10808

git config --global http.proxy socks5://127.0.0.1:10808

3 手动配置(ssh 代理)

3.1 Windows

编辑 %userprofile%/.ssh/config(.ssh 不存在就自己创建这个文件夹),写入
file

Host github.com
    User git
    ProxyCommand connect -H [IP]:[Port] %h %p

这里就直接使用本机 http 代理 ssh,所以写入

Host github.com
    User git
    ProxyCommand connect -H 127.0.0.1:10809 %h %p

3.2 Linux(Debian、Ubuntu…)

编辑 ~/.ssh/config(.ssh 不存在就创建),写入
(以本机 http 代理为例)

Host github.com
    User git
    ProxyCommand nc -X connect -x 127.0.0.1:10809 %h %p