Improve the Github Experience
I personally prefer to host my code on Github, but for well-known reasons, pulling code from the server often times out or runs into other issues. Here I’m sharing a solution.
Contents
Optimize the GitHub Experience
I personally prefer to store my code on GitHub, but for well-known reasons, servers often run into timeouts and other issues when pulling code. Here I’ll share a solution (note that this is not suitable for production environments, and stability is not guaranteed).
[Inspired by] https://github.com/ineo6/hosts
Download and Import the Hosts File
wget https://raw.githubusercontent.com/frankwuzp/github-host/main/hosts -O hosts.temp
# 无法使用选择giee源或者下载了传上去。
cat /etc/hosts >> hosts.temp
mv hosts hosts.bak
mv hosts.temp /etc/hosts
# 追加Hosts并备份。
Writing a Script to Automate Replacement
#! /bin/bash
curl https://raw.githubusercontent.com/frankwuzp/github-host/main/hosts > /etc/hosts
cat /etc/hosts.bak >> /etc/hosts
Configure execution permissions.
chmod +x update-hosts.sh
Configure a Scheduled Task to Automatically Fetch the Latest Hosts Daily
crontab -e
30 4 * * * /root/tool/github-hosts/update.sh
# 每天4点半执行更新
The same approach also applies to Windows. You can use Task Scheduler to configure automatic updates.