Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save the-eric-kwok/bf790e7c9df46d39bc0451ac28f0b516 to your computer and use it in GitHub Desktop.
Save the-eric-kwok/bf790e7c9df46d39bc0451ac28f0b516 to your computer and use it in GitHub Desktop.

https/http 协议的执行:

# 设置 http 代理
git config --global https.proxy http://127.0.0.1:8080

# 或 socks5 代理
git config --global http.proxy socks5h://127.0.0.1:1080

# 取消代理
git config --global --unset http.proxy

或者你希望只针对 GitHub 设置代理:

#只对github.com
git config --global http.https://github.com.proxy socks5h://127.0.0.1:1080

#取消代理
git config --global --unset http.https://github.com.proxy

如果是 git 协议的则需要在 ~/.ssh/config 中添加:

Host github.com
  ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p

如果提示 nc: Command not found 的话可以尝试改为

Host github.com
  ProxyCommand connect -S 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