2021-07-04 通过vmess对git进行代理(全局代理)

本文介绍了如何通过Git配置设置本地http/https代理以及socks5代理,以解决在使用hexo等工具向GitHub推送时遇到的网络超时问题。同时提供了针对GitHub的特定代理设置方法,以及SSH协议下配置socks5代理的步骤,确保在各种网络环境下能顺利进行代码同步和仓库更新。
摘要由CSDN通过智能技术生成

设置命令

#设置使用http/https本地代理
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
#取消http/https本地代理
git config --global --unset http.proxy
git config --global --unset https.prox

以上方式如果还不能解决,可以再次尝试设置sock5代理:

git config --global http.proxy ‘socks5://127.0.0.1:1080’
git config --global https.proxy ‘socks5://127.0.0.1:1080’

如果只针对GitHub设置代理,则用如下命令:

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

对于使用 ssh:// 协议的,可以配置socks5代理,在 ~/.ssh/config 文件内容后面添加几行:

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

适用场景

  1. hexo等发布到GitHub时失败,错误提示:“xx time out”
  2. 更新GitHub仓库无响应 $ git push ssh:
    connect to host github.com port 22: Network is unreachable fatal:
    The remote end hung up unexpectedly
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值