Last active
January 24, 2025 05:48
-
Star
(1,199)
You must be signed in to star a gist -
Fork
(278)
You must be signed in to fork a gist
-
-
Save laispace/666dd7b27e9116faece6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
实测如下, 详细见: 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
thanks a lot!