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

相关推荐
云中飞鸿11 分钟前
git、svn;TortoiseGit、TortoiseSVN;gitlab、github、bitbucket、bamboo有什么关系?
git·svn·gitlab
狐571 小时前
2026-03-15-因服务器网络访问问题从 GitHub 平滑迁移至 Gitee 等国内平台的方法
服务器·gitee·github
草梅友仁8 小时前
墨梅博客 1.9.0 发布与 LeanCloud 停服应对 | 2026 年第 11 周草梅周报
开源·github·ai编程
朱包林9 小时前
Python基础
linux·开发语言·ide·python·visualstudio·github·visual studio
qqxhb11 小时前
04|最小工程素养:文件、命令行、依赖、环境变量、Git
git·环境·依赖·工程·项目结构
sunny_13 小时前
📖 2026年 大厂前端面试手写题库已开源(2.3k star)
前端·面试·github
国家二级编程爱好者16 小时前
删除typora文档没有引用的资源文件
git·python
阿里嘎多学长16 小时前
2026-03-11 GitHub 热点项目精选
开发语言·程序员·github·代码托管
Yupureki16 小时前
《C++实战项目-高并发内存池》5.PageCache构造
c语言·开发语言·c++·单例模式·github
Rsun0455119 小时前
Git相关面试题
git