GitHub下载太慢的解决方案

修改hosts文件:

windows的hosts文件在
C:\Windows\System32\drivers\etc\hosts

cmd管理员运行命令notepad C:\Windows\System32\drivers\etc\hosts

然后cmd命令重启网络ipconfig /flushdns
windows修改hosts

Ubuntu22.04修改hosts
sudo vim /etc/hosts

bash 复制代码
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1       localhost
127.0.1.1       localhost.      localhost
<feff>
192.168.1.8     host.docker.internal
192.168.1.8     gateway.docker.internal
127.0.0.1       kubernetes.docker.internal
20.205.243.166  https://github.com/

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
20.205.243.166 github.com

~                                                                                                             ~                                                                                                             ~                                                                                                             ~                                                                                                             ~                                                                                                             "/etc/hosts" 19L, 576C                                                                      19,0-1        All 

在文末添加20.205.243.166 github.com

然后在终端刷新DNS缓存sudo systemd-resolve --flush-caches

其中20.205.243.166是在站长工具-ping检测内查找。

站长工具使用方法是把需要查找的网址放进去,如 github.com,然后选择延迟最小的IP地址放进hosts内。

我们也可以直接登录20.205.243.166直达GitHub

解决GitHub下载速度太慢问题的方法汇总

下面是chatgpt3.5给出的答案:

在Ubuntu 22.04.6版本中,您可以使用以下命令使修改的hosts文件立即生效:

  1. 打开终端。您可以使用快捷键Ctrl + Alt + T来打开终端。

  2. 输入以下命令以编辑hosts文件(需要root权限):

bash 复制代码
sudo nano /etc/hosts

上述命令将使用nano文本编辑器打开hosts文件。您也可以使用其他文本编辑器。

  1. 对hosts文件进行必要的修改,例如添加或修改主机名和IP地址。

  2. 保存并关闭文件编辑器。

  3. 使用以下命令刷新网络设置以使修改生效:

bash 复制代码
sudo systemd-resolve --flush-caches

上述命令将刷新DNS缓存以应用新的hosts文件。

  1. 如果您使用的是网络管理器,请使用以下命令重启网络管理器:
bash 复制代码
sudo service network-manager restart

完成上述步骤后,您的修改应该立即生效。您可以尝试通过ping或在浏览器中访问相应的主机名来验证修改是否生效。请注意,上述命令可能因发行版和网络配置而有所不同。在某些情况下,您可能需要运行适合您的系统的其他命令。

相关推荐
攀登的牵牛花38 分钟前
本周 GitHub 趋势观察:为什么前端热榜越来越像“AI 工具市场”?
前端·github
第一程序员1 小时前
Python游戏开发:从入门到实践
python·github
殷紫川2 小时前
IDEA 集成 GitHub Copilot 指南:解锁 10 倍编码效率的全链路实战
github·intellij idea·github copilot
八号老王4 小时前
Google Cloud Vertex AI 接入 OpenClaw 记录
github
子兮曰5 小时前
同样做中文平台自动化:为什么你越跑越贵,而 OpenCLI 越跑越稳
前端·github·命令行
CoderJia程序员甲5 小时前
GitHub 热榜项目 - 日榜(2026-04-01)
人工智能·ai·大模型·github·ai教程
我先去打把游戏先6 小时前
Git 一个本地仓库同时推送到两个远程仓库(私人 GitHub + 公司 Git)保姆级教程
git·vscode·单片机·嵌入式硬件·物联网·学习·github
汪海游龙6 小时前
04.02 AI 精选:终端里的 AI 编程代理工具
github
看海的四叔7 小时前
【Linux】命令行常规操作全攻略:入门+实战+速查
linux·运维·github·命令行·batch命令
今夕资源网7 小时前
github开源桌面快速启动神器:ZTools 高性能 可扩展应用启动器,支持macOS/Windows,适配办公与开发需求
macos·github·工具箱·ztools·桌面启动·音速启动·高性能启动器