Skip to content

Instantly share code, notes, and snippets.

@laispace
Last active February 8, 2025 10:24
Show Gist options
  • Save laispace/666dd7b27e9116faece6 to your computer and use it in GitHub Desktop.
Save laispace/666dd7b27e9116faece6 to your computer and use it in GitHub Desktop.
git config --global https.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
npm config delete proxy
@liuyunbin
Copy link

liuyunbin commented Jan 2, 2025

实测如下, 详细见: https://gist.github.com/liuyunbin/b6b820ecca264e2768e6574dc4235763#git

# 1. http 协议
git config --global http.proxy   http://192.168.68.1:7890; # 设置 http  代理
git clone https://github.com/liuyunbin/note;               # 测试
git config --global --unset http.proxy;                    # 取消代理设置

git config --global http.proxy socks5h://192.168.68.1:7890; # 设置 socks5h  代理
git clone https://github.com/liuyunbin/note;                # 测试
git config --global --unset http.proxy;                     # 取消代理设置

# 2. ssh 协议访问
# 2.1 windows 10 --- git-bash
在 ~/.ssh/config 中添加:  --- http  代理
    Host github.com
    ProxyCommand connect -H 192.168.68.1:7890 %h %p
git clone git@github.com:liuyunbin/note; # 测试    
    
在 ~/.ssh/config 中添加:  ---  socks 代理
    Host github.com
    ProxyCommand connect -S 192.168.68.1:7890 %h %p
git clone git@github.com:liuyunbin/note; # 测试      

# 2.2 centos 7
在 ~/.ssh/config 中添加:   --- http  代理
    Host github.com
    ProxyCommand nc --proxy-type http --proxy 192.168.68.1:7890 %h %p
git clone git@github.com:liuyunbin/note; # 测试

在 ~/.ssh/config 中添加:   --- socks5 代理
    Host github.com
    ProxyCommand nc --proxy-type socks5 --proxy 192.168.68.1:7890 %h %p
git clone git@github.com:liuyunbin/note; # 测试

# 2.3 ubuntu 24.04
在 ~/.ssh/config 中添加: --- http 代理
    Host github.com
    ProxyCommand nc -X connect -x 192.168.68.1:7890 %h %p
git clone git@github.com:liuyunbin/note; # 测试

在 ~/.ssh/config 中添加: --- socks5 代理
    Host github.com
    ProxyCommand nc -X 5 -x 192.168.68.1:7890 %h %p
git clone git@github.com:liuyunbin/note; # 测试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment