When GitHub occasionally won't load, I first figure out whether it's a DNS resolution problem or whether the network simply can't reach it. Editing hosts might help with the former, but it's not a proxy—it won't bypass a firewall or fix a TLS connection.
Where to get the hosts entries
I use maxiaof/github-hosts. The project provides resolution records for GitHub and related resource domains, and the update URL is the hosts file.
IP addresses change, so copying a fixed list is easy to get wrong. Go to the project and check the latest file, verify the domains and update date, then replace only the section you added.

Diagram: hosts changes resolution, not the network path
In the diagram, hosts and DNS are the resolution path, and the network connection afterward is a separate matter. Getting an IP doesn't guarantee you can actually connect.
Back up before you edit
On Windows the file is at C:\Windows\System32\drivers\etc\hosts; on macOS and Linux it's at /etc/hosts. Make a copy first, then edit with administrator privileges. Don't overwrite the existing localhost entries, development domain names, or other business configurations in the file.
Leave a clear pair of comments around what you add, for example # GitHub hosts begin and # GitHub hosts end. When you update later, replace only the records between those two lines—don't keep appending the entire downloaded file each time.
Flush the cache and check
On Windows, run this in an administrator terminal:
ipconfig /flushdns
On macOS, run this in the terminal:
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
Linux has no single cache command that works across all distributions. If the machine uses systemd-resolved, run:
sudo resolvectl flush-caches
Only machines using nscd need to restart nscd; if those services aren't enabled, don't copy that step. sudo nscd restart is not a universal way to manage the service.
Then reopen your browser and check whether the GitHub page, images, and repository files each load. On Linux you can also use getent hosts github.com to see the system's resolution result. nslookup usually queries DNS directly, so you can't use it alone to tell whether hosts is taking effect.
If the homepage loads but raw files or avatars still fail, check whether those domains are also covered by the project. If connections keep timing out, revert the records you just added and keep investigating the network, proxy policy, and firewall; don't disable certificate validation to paper over the problem.
References: project README, systemd-resolved documentation.