为git设置代理

为git设置sock5代理

为git设置sock5代理

git config --global http.proxy 'socks5://127.0.0.1:7891' #改成自己的端口
git config --global https.proxy 'socks5://127.0.0.1:7891'

# 查看是否成功
git config -l #查看git的所有配置

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

为git设置ssh代理

由于我们推送的时候github只能走ssh协议,因此还需要设置ssh的代理。
修改~/.ssh目录下的config文件,若没有则新建

Host github.com
        Hostname ssh.github.com
        Port 443
        User git
        ProxyCommand nc -v -x 127.0.0.1:7891 %h %p

nc命令需要安装工具netcat。

sudo apt install netcat

检查是否ssh代理成功?

ssh -T git@github.com

如果出现,Successful则表示成功。

参考链接

设置http代理
设置sock代理
设置ssh代理

posted @ 2024-08-01 22:59  Ladisson-blog  阅读(149)  评论(0)    收藏  举报