Mirror Public Repositories
2 minute reading time
Git is designed to be decentralized. However, many people treat it as a centralized solution by depending on services such as GitHub. What we’ve seen through the youtube-dl debacle is that repositories that we depend on can be taken down.
This isn’t to say that GitHub is evil and that we should move to Bitbucket, Gitlab, Source Hut, etc. But this is more of a commentary on what happens when we depend on one service to host our code. Git is designed to be decentralized, we should make use of that fact!
Also, alleged illegal activity is not the only reason repositories are taken down from the Internet. Sometimes, the developer themselves decide to take it down.
As individuals, we can maintain mirrors of repositories we care about. That way if it ever gets removed from a particular service, we’re not out of luck.
The simplest way to go about this is to
git clone the repositories you care about, and regularly
pull through a cron job or systemd timer. Through systemd maybe it’ll look like this:
Description=Pull latest changes from Hugo
Description=Pull latest changes from Hugo every week
Alternatively, you can use a self-hosted git server instance such as Forgejo to set up pull mirrors through the migration tool. As of the time of writing, this is what I currently do with repositories at https://git.brandonrozek.com/github
I do recommend only mirroring/pulling infrequently such as weekly. We don’t want to induce unnecessary load on these centralized services.