DEV Community

Mark
Mark

Posted on

Stop Pushing to Main. A 25-Year Veteran Explains Why Junior Devs Break Production Every Single Time

Most junior developers are one bad git push away from taking down their entire team.

I've seen it happen hundreds of times across 25 years in the industry β€” and the fix is simpler than you think.

After a quarter century of watching teams struggle, I can tell you with confidence: the teams that are constantly putting out fires aren't struggling because of bad code. They're struggling because of bad workflow habits that nobody ever bothered to teach them properly.

This isn't theory from a textbook. This is 25 years of watching what works, what doesn't, and what makes senior devs quietly sigh at standup.


😩 01 β€” The Relatable Pain

Raise your hand if you've ever pushed directly to main and thought "it's fine, it's just a tiny change."

Yeah. We've all done it. This is a safe space.

Most junior developers β€” and honestly a fair few mid-level devs too β€” treat git like it's basically just a cloud backup button. Commit to main, push, done. It works great! Right up until the moment it very, very much doesn't.

One bad push. The whole team is blocked. Someone's on-call phone goes off at 2am. Hot-fix on top of hot-fix on top of regret and cold brew coffee.

"It's just a small fix, CI will be fine." β€” Famous last words, every time.

Sound familiar? Good. That's exactly what we're fixing today.


🧠 02 β€” The Senior Insight

Here's how experienced developers actually think about this β€” and it's probably not what you expect.

A calm, battle-tested senior engineer doesn't panic when things go sideways. And the reason they don't panic is because they have a system. They've been burned enough times to build the guardrails before the fire starts.

Their whole mantra:

"Branches are free. Pride is expensive."

These folks protect main like it's production β€” because it IS production, or it's about to be. Feature branches for everything. Even tiny tweaks. Not because they enjoy clicking buttons, but because they've seen what happens when you don't.

Pull Requests aren't annoying gatekeeping. They're not there to slow you down. They're your safety net β€” the thing that catches the bug your tired eyes missed at 4:47pm on a Thursday.

The question a good senior always has in the back of their mind: if something goes wrong right now, how long does it take us to revert?

The goal is 2 minutes, not 2 hours.


πŸ’‘ 03 β€” Concrete Example: GitHub Flow in Practice

Enough theory. Here's what it actually looks like on a real team.

The team adopts GitHub Flow. Dead simple. You've got main, and you've got feature branches. That's basically it.

Starting a new feature:

git checkout -b feat/user-auth
Enter fullscreen mode Exit fullscreen mode

Work in isolation. Nobody else is affected. When you're done, open a PR, someone reviews it, it gets merged into main. Clean.

Bug in production?

git checkout -b hotfix/login-crash
# fix it
git push origin hotfix/login-crash
# open PR β†’ review β†’ merge back to main
Enter fullscreen mode Exit fullscreen mode

Branch off main for the hotfix, patch it, merge back in.

And here's the rule that makes the whole thing work:

Nobody touches main directly. Not the juniors, not the seniors, not the tech lead who's been there since the company was three people in a WeWork. Nobody.

The result?

  • βœ… A clean, readable commit history
  • βœ… Easy rollbacks when (not if) something goes wrong
  • βœ… A team that isn't constantly putting out fires they accidentally started themselves

πŸ—ΊοΈ 04 β€” The Mental Model: Think in Rivers

I want to give you a mental model that actually sticks.

Think of main as a river. It's always flowing. It's always clean. You want the water that reaches the ocean to be good water.

Feature branches are tributaries β€” smaller streams that branch off and eventually flow back in.

A Pull Request is the quality check that happens before that tributary water hits the main river. You're asking: is this clean enough to join the main flow?

And here's the beautiful part: if a tributary gets polluted β€” if a feature branch is a total mess β€” it doesn't ruin the whole river. You fix it in the side stream, in isolation, where it can't hurt anyone.

main ──────────────────────────────────────► (production)
        β”‚                        β–²
        └── feat/user-auth β”€β”€β”€β”€β”€β”€β”˜  (PR reviewed βœ“)
              β”‚
              └── No review? Stays here. Forever.
Enter fullscreen mode Exit fullscreen mode

Simple rule to tattoo somewhere visible:

If it hasn't been reviewed, it doesn't touch main.

That's the entire mental model. It scales from 3 people to 300.


πŸš€ 05 β€” One Takeaway You Can Apply Tomorrow

One thing. Just one thing I want you to take away from this.

Tomorrow morning β€” before you open Slack, before you check your emails, before you do literally anything else β€” do this:

  1. Go to your repository on GitHub or GitLab
  2. Find Settings β†’ Branches β†’ Branch protection rules
  3. Add a rule for main
  4. Enable "Require a pull request before merging"
  5. Set required reviewers to at least 1
  6. Save

That's it. Two minutes. Zero code written. And that one tiny change will save your team hours of pain, awkward Slack threads, and late-night incident calls for months to come.

Your future self β€” specifically the version of you that doesn't get paged on a Sunday afternoon β€” will send you a genuine, heartfelt thank-you note.

I know it can feel like overhead when you're a small team moving fast. But the teams that skip this step are the ones writing post-mortems about completely avoidable outages six months later. Don't be that team.


πŸ“‹ The Cheat Sheet

# Section The One-Liner
01 😩 The Pain Committing to main = chaos waiting to happen
02 🧠 Senior Mindset Branches are free. Protect main like it's prod.
03 πŸ’‘ GitHub Flow Feature branch β†’ PR β†’ review β†’ merge. Every time.
04 πŸ—ΊοΈ The River Model main is clean water. PRs are your filter.
05 πŸš€ Do This Tomorrow Enable branch protection. 2 minutes. Zero excuses.

Wrapping Up

After 25 years in this industry, the thing that still surprises me isn't that junior developers make these mistakes β€” it's that nobody ever sits them down and explains why the guardrails exist in the first place.

Git workflows aren't bureaucracy. They're the distilled scar tissue of every team that shipped a bad push on a Friday and spent the weekend fixing it.

Start with branch protection. Build the habit. Everything else follows.


If this was useful, drop a comment below β€” I want to know: what's the worst git disaster you've ever caused or witnessed? No judgment. We've all been there. πŸ‘‡

Note: This article was written with AI assistance to help structure and articulate 25+ years of debugging experience. All examples, insights, and methodologies are from real-world experience.

Top comments (0)