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

相关推荐
ljh5746491191 小时前
PhpStorm 2022.3 版本中,修改使用 Git 提交时看到弹出式的对话框模式
ide·git·php·phpstorm
云闲不收3 小时前
git rebase
git
江上清风山间明月3 小时前
git pull和git checkout在恢复文件的区别
git·pull·checkout
海鸥814 小时前
in argocd ‘/tmp/_argocd-repo/../.git/index.lock‘: No space left on
git·argocd
用户21991679703915 小时前
.Net通过EFCore和仓储模式实现统一数据权限管控并且相关权限配置动态生成
后端·github
尔嵘5 小时前
git操作
大数据·git·elasticsearch
好评1245 小时前
Linux文件上传git
linux·运维·git
大柏怎么被偷了7 小时前
【Git】企业级开发模型
git
Garfield20058 小时前
Git 分支拓扑实践
git·拓扑
DKNG8 小时前
【Windows Host】 hosts配置增加访问github流畅度
人工智能·git·github