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

相关推荐
yyuuuzz8 小时前
aws亚马逊入门常见认知误区
运维·服务器·网络·云计算·github·aws
___波子 Pro Max.11 小时前
Git Remote 仓库地址变更
git
逛逛GitHub13 小时前
你的 Mac 就是一个 AI Agent,4B 模型本地操控电脑。
github
铁皮哥15 小时前
【后端/Agent 开发】给你的项目配置一套 .claude/ 工作流:别再裸用 Claude Code 了!
java·windows·python·spring·github·maven·生活
ModestCoder_15 小时前
Git 忽略所有 `.xlsx`,但保留指定 Excel 文件的方法
git·excel
阡陌..17 小时前
202605新版git_2.54.0常用操作指令
大数据·git·elasticsearch
Resistance丶未来17 小时前
Agency-Agents 多智能体协作系统落地指南
python·大模型·nlp·github·copilot·claude·gemini
輕華17 小时前
YOLOv5 实战:从 GitHub 拉取到自定义数据集训练
yolo·github
会笑的小熊17 小时前
VScode项目推送到git仓库
ide·git·vscode
zhangfeng113317 小时前
宝塔服务器完全可以安装 Git,进行版本管理,而且非常简单
运维·服务器·人工智能·git·编程