对于国内开发者而言,访问 GitHub 时经常遇到页面加载缓慢、图片无法正常显示等问题,严重影响开发效率与使用体验。GitHub520 是一个专注于解决此类网络访问问题的开源项目,通过自动维护并分发经过优化的 hosts 文件配置,帮助用户在不借助代理工具的情况下,显著改善 GitHub 的访问质量。
该项目由社区持续维护,hosts 列表会根据网络状况自动定时更新,确保 IP 地址的可用性与时效性。整个过程无需安装任何额外软件,用户仅需简单修改系统 hosts 文件即可完成配置,整个过程耗时约 5 分钟。

核心功能与解决问题
GitHub520 主要解决以下两类常见问题:
- 访问速度慢:通过将 GitHub 及其相关域名指向响应速度更快的 CDN 节点 IP,缩短网络请求延迟。
- 图片加载失败:针对
raw.githubusercontent.com、camo.githubusercontent.com等图片资源域名进行解析优化,解决项目页面中图片裂图、头像无法显示等问题。
项目覆盖的域名包括 GitHub 主站、API 接口、代码托管、头像服务、附件下载、GitHub Pages 等核心服务,确保用户能够完整、流畅地使用 GitHub 的各项功能。
多种部署方式
手动配置
用户可直接从 https://raw.hellogithub.com/hosts 获取最新的 hosts 内容,将其追加至系统 hosts 文件末尾:
- Windows:文件位于
C:\Windows\System32\drivers\etc\hosts,使用记事本以管理员权限编辑。 - macOS / Linux:文件位于
/etc/hosts,需使用sudo权限执行编辑命令,如sudo vi /etc/hosts。 - Android / iOS:需获取 Root 或越狱权限后修改
/system/etc/hosts或/etc/hosts。
修改完成后,需刷新 DNS 缓存使配置生效:
- Windows:在 CMD 执行
ipconfig /flushdns - macOS:执行
sudo killall -HUP mDNSResponder - Linux:执行
sudo nscd restart(如未安装可使用sudo apt install nscd)
SwitchHosts 自动管理(推荐)
SwitchHosts 是一款跨平台的 hosts 文件管理工具,支持远程 hosts 订阅与自动更新。配置步骤如下:
- 打开 SwitchHosts,点击添加新配置
- 类型选择 “Remote”
- URL 填写:
https://raw.hellogithub.com/hosts - 设置自动刷新周期为 1 小时
配置完成后,SwitchHosts 会在后台自动拉取最新配置,无需手动干预。
命令行一键更新
对于习惯终端操作的用户,项目提供了各平台的一键更新脚本:
Windows(需安装 Git Bash):
_hosts=$(mktemp /tmp/hostsXXX) hosts=/c/Windows/System32/drivers/etc/hosts remote=https://raw.hellogithub.com/hosts reg='/# GitHub520 Host Start/,/# Github520 Host End/d' sed "$reg" $hosts > "$_hosts" curl "$remote" >> "$_hosts" cat "$_hosts" > "$hosts" rm "$_hosts"
Linux / Ubuntu / CentOS / Fedora:
sudo sh -c 'sed -i "/# GitHub520 Host Start/Q" /etc/hosts && curl https://raw.hellogithub.com/hosts >> /etc/hosts'
macOS / BSD:
sudo sed -i "" "/# GitHub520 Host Start/,/# Github520 Host End/d" /etc/hosts && curl https://raw.hellogithub.com/hosts | sudo tee -a /etc/hosts
上述命令可配合 cron 定时任务或 Windows 任务计划程序实现自动更新。
AdGuard 集成
AdGuard 用户可在 “过滤器 > DNS 封锁清单” 中添加自定义列表,URL 同样使用 https://raw.hellogithub.com/hosts,并将过滤器更新间隔设置为 1 小时。此方法适用于 AdGuard for Windows、macOS、Android 及 iOS 全系列软件。
数据来源与更新机制
GitHub520 项目通过自动化脚本定期检测各域名的最优解析 IP,hosts 文件内容每日自动更新。用户可通过以下地址获取不同格式的数据:
- 文本格式:
https://raw.hellogithub.com/hosts - JSON 格式:
https://raw.hellogithub.com/hosts.json
项目遵循 “署名-非商业性使用-禁止演绎”(CC BY-NC-ND 4.0)开源协议,供个人学习与非商业场景免费使用。
获取方式
GitHub520 为开发者提供了一种轻量级、无依赖的 GitHub 网络优化方案,特别适合不便使用代理工具或希望提升访问稳定性的用户。通过简单的 hosts 文件配置,即可显著改善 GitHub 的访问体验。
用过还觉还是不好用呢[允悲]