跳到主要内容

Git

Git 代理

需要注意代理是 127.0.0.1 还是localhost 生效

还要确认是 ssh 还是 https

配置 Https 代理

  • 设置或取消代理
git config --global https.proxy http://127.0.0.1:1080

git config --global https.proxy https://127.0.0.1:1080

或者 是localhost
git config --global http.proxy http://localhost:7890
git config --global https.proxy https://localhost:7890

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

git config --global --unset https.proxy

配置 SSH 代理

Mac

  • ~/.ssh/config
Host github.com
User git
ProxyCommand nc -v -x 127.0.0.1:7890 %h %p

Linux (Ubuntu)

  • ~/.ssh/config
    Host github.com
ProxyCommand nc -X connect -x 192.168.68.1:7890 %h %p

Windows 系统shell

  • .ssh/config 配置文件
Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 22
ProxyCommand connect -S 127.0.0.1:7890 %h %p

Windows Git shell

找到Git shell 的路径,
比如:
C:\Program Files\Git\etc\ssh\ssh_config

在这里配置

Host github.com
User git
ProxyCommand connect -S 127.0.0.1:7891 %h %p

参考