怎么在 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 就显得轻而易举了。

相关推荐
午安~婉10 小时前
GitHub Token/ GitHub Stats统计显示图异常
前端·github·vercel·github token
.Hypocritical.10 小时前
Git 入门教程
git
dong_junshuai11 小时前
每天一个开源项目#59 AirLLM:27.6K星,3.72GB显存跑2.8T模型
人工智能·程序员·github
lpfasd12311 小时前
2026年第31周GitHub趋势周报
github
Jul1en_13 小时前
【Claude Code Compact】源码级别的学习上下文压缩
java·前端·学习·github·ai编程
逛逛GitHub13 小时前
Karpathy 刚发了一个帖子,怎么判断一个新模型到底行不行?
github
m4Rk_14 小时前
【论文阅读】Agent 记忆机制(28):MEM1——将记忆压缩融入推理,实现近似恒定上下文的长程智能体
论文阅读·人工智能·学习·开源·github
逛逛GitHub14 小时前
盘点 17 个 7 月份 GitHub 上夯夯夯的开源项目。
github
AI行业学习16 小时前
Claude Code + cc-switch + Git + Node.js 全套下载+安装+配置完整版
开发语言·git·python·前端框架·node.js·html·notepad++
豆角焖肉17 小时前
.gitignore:配置文件+初学入门
git·gitignore