Skip to content

Instantly share code, notes, and snippets.

@hsiafan
Last active March 27, 2023 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsiafan/b3ae7a0b8d101b846ec8a242a9aac0f3 to your computer and use it in GitHub Desktop.
Save hsiafan/b3ae7a0b8d101b846ec8a242a9aac0f3 to your computer and use it in GitHub Desktop.
git proxy
# git 两种模式:SSH 、HTTP
# proxy 两种模式:SOCKS 、HTTP
# 两两组合,共 4 种设置,请按需正确配置:
# 1. git http + proxy http
git config --global http.proxy "http://127.0.0.1:1080"
git config --global https.proxy "http://127.0.0.1:1080"
# 2. git http + proxy socks
git config --global http.proxy "socks5://127.0.0.1:1080"
git config --global https.proxy "socks5://127.0.0.1:1080"
# to unset
git config --global --unset http.proxy
git config --global --unset https.proxy
# 3. git ssh + proxy http
vim ~/.ssh/config
Host github.com
HostName github.com
User git
ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=1087
# 4. git ssh + proxy socks
vim ~/.ssh/config
Host github.com
HostName github.com
User git
ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment