问题描述
我从github clone一些项目的时候速度极慢,有时候clone到一半还会失败,简直令人抓狂。
解决步骤
1. 使用国内镜像网站
目前已知Github国内镜像网站有github.com.cnpmjs.org(亲测这个访问速度较快)和git.sdut.me/。你可以根据你对这两个网站的访问速度快慢,选择其中一个即可。接下来只需要在clone某个项目的时候将github.com替换为github.com.cnpmjs.org即可。如下例:
git clone https://github.com/Hackergeek/architecture-samples
替换为
git clone https://github.com.cnpmjs.org/Hackergeek/architecture-samples
或者
git clone https://git.sdut.me/Hackergeek/architecture-samples
如果你仅仅只是想clone项目,不需要对clone下来的项目进行modify和push,那下面那个步骤就不需要看了。下面的步骤是为了解决使用镜像网站clone下来的项目无法进行push的问题的,因为国内的镜像网站是无法登录的,如果你尝试登录,结果如下图。
2. 修改仓库push url
为了解决使用国内镜像网站clone下来的项目无法push的问题,我们需要将clone下来的仓库push url修改为github.com。如下例:
使用国内镜像网站clone下来的项目远程仓库地址如下图:
使用如下命令修改仓库的push url:
git remote set-url --push origin https://github.com/Hackergeek/architecture-samples
过程如下图:
Github镜像站列表(更新于2023-03-10)
Github镜像站网址 |
更新时间 |
https://hub.njuu.cf/ |
2023-03-10 |
https://hub.yzuu.cf/ |
2023-03-10 |
https://hub.nuaa.cf/ |
2023-03-10 |
https://hub.fgit.ml/ |
2023-03-10 |
为了解决镜像站失效问题,在此提供上面这份Github镜像站列表。各位可以自行fork项目,然后替换源码中的Gihtub镜像站网站。如果你们知道一些不错的Github镜像站,欢迎提供。
参考资料
- Openpilot 国内镜像
- git clone一个github上的仓库,太慢,经常连接失败,但是github官网流畅访问,为什么?
GitHub: Let’s build from here、hub.yzuu.cf/、hub.nuaa.cf/、hub.fgit.ml/