Github被墙?设置Git全局代理,解决无法pull和push问题

您所在的位置:网站首页 windows如何关闭代理 Github被墙?设置Git全局代理,解决无法pull和push问题

Github被墙?设置Git全局代理,解决无法pull和push问题

2024-07-13 06:58| 来源: 网络整理| 查看: 265

最近是不是 Github 又被墙了?从昨天开始,推送和拉取代码都报这样的错误:fatal: unable to access 'https://github.com/ideshun/fin-ai.git/': Recv failure: Connection was reset ,搞人心态。

这些人真是闲的没事吃饱了撑的,今天又把知名 CDN jsdelivr.com 给墙了。

通过配置代理解决 Github 不能 pull 和 push 的问题

如果你有代理的话,可以通过以下方式设置 Git 代理:

设置 Git 全局代理

设置全局代理为 http://127.0.0.1:10809 或 socket5://127.0.0.1:10808:

代码语言:javascript复制git config --global http.proxy 'http://127.0.0.1:10809' git config --global https.proxy 'http://127.0.0.1:10809' # OR git config --global http.proxy 'socks5://127.0.0.1:10808' git config --global https.proxy 'socks5://127.0.0.1:10808'

这里的 10808 和 10809 是代理的端口号,应该替换为你自己的代理端口号。

设置当前项目 Git 代理

如果我们有私有项目,比如公司有自己的 GitLab 仓库,设置全局代理就不合适了,可以给某一个项目设置代理。在需要代理的 Git 项目中执行下面的命令:

代码语言:javascript复制git config --local http.proxy '127.0.0.1:10809' git config --local https.proxy '127.0.0.1:10809'

这里的参数: --global 代表全局,--local 代表当前项目。

取消代理

取消全局代理:

代码语言:javascript复制git config --global --unset http.proxy git config --global --unset https.proxy

取消当前项目代理:

代码语言:javascript复制git config --local --unset http.proxy git config --local --unset https.proxy查看代理配置

代理设置完,查看是否成功,可以通过下面的命令,查看当前代理配置:

代码语言:javascript复制git config --global http.proxy git config --global https.proxy

未经允许不得转载:Web前端开发资源网 » Github被墙?设置Git全局代理,解决无法pull和push问题



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3