怎么在 push 代码到 github 时用上小飞机?

最近很多朋友都提到 github 很难打开,开了小飞机能访问 github 网站了,但是在 push 代码时又没办法 push 上去。

遇到的报错日志大概是这样的:

vbnet 复制代码
fatal: unable to access 'https://github.com/your-user-name/your-repo.git/': Failed to connect to github.com port 443 after 21057 ms: Timed out

很明显,是网络超时了。并且重试很多次也没有什么起色。

我们心里可能会想,明明我已经科学上网了,为啥 github 还 push 不上去?这是因为 git 默认是不会使用系统网络代理的,即便我们的某猫工具已经被设置为系统网络代理,还是解决不了往 github push 代码的问题。

那么怎么在 push 代码到 github 时用上小飞机呢?

其实只要用到网络请求的,基本上都可以设置代理,git 也不例外。

首先,我们找到代理工具的网络端口,以某猫为例,一般是 7890 端口。

然后,通过 git 提供的配置能力设置 http 和 https 代理。

我们可以先查看一下之前有没有设置过代理,

lua 复制代码
git config --global http.proxy
git config --global https.proxy

如果执行上述命令后没有任何输出,说明没有设置过代理,此时可以执行以下命令:

lua 复制代码
git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890

此时再 push 代码到 github 就显得轻而易举了。

相关推荐
baozj1 小时前
把徒步轨迹做成 3D 地形模型:开源工具「印迹 TrailPrint 3D」
前端·vue.js·github
m0_579146651 小时前
Git 重置模式详解:四种重置方式的原理与应用场景
git
恋喵大鲤鱼1 小时前
git grep
git·git grep
逛逛GitHub1 小时前
这 2 个免费的开源 Skill 太给劲儿,直接替代 Playwright。
github
uhakadotcom1 小时前
什么是Mass Assignment(批量赋值)风险
后端·面试·github
霸王龙的小胳膊1 小时前
Git基础知识
git
Harvy_没救了2 小时前
【github爆款】MarkItDown 部署与测评报告
github
comcoo2 小时前
避坑指南:OpenClaw v2.7.9 Windows/macOS 零基础安装全过程
人工智能·windows·macos·github·开源软件·open claw·open claw部署包
恋喵大鲤鱼2 小时前
git fetch
git·git fetch
Java知识技术分享2 小时前
安装sourcetree
java·git·源代码管理