GitHub
Protect Your Main Branch: A Cautionary Tale
I learned this lesson the hard way. I was working on a personal project, had a great idea, and pushed directly to `main`. Everything broke. The site went down. My beautiful, functional app was replaced with a half-finished feature. I spent the next hour frantically trying to remember what the last working version was. Now, I always protect my `main` branch. I set up branch protection rules on GitHub so that you can’t push directly to it. Every change requires a pull request and at least one review (even if that reviewer is just me, checking my own work). It adds a tiny bit of friction, but it prevents the heart attack of accidentally breaking production.
1,896
Views
117
Words
1 min read
Read Time
Sep 2025
Published