r/github • • 15d ago

Discussion What’s the worst GitHub mistake you’ve made, and how did you fix it?

I ran git push --force on the main branch and wiped out a teammate’s commits from that morning. My heart dropped.

Luckily, my teammate still had the commits on their local machine, so they pushed them back. After that, we turned on branch protection so no one can force-push to main again.

Now I’m curious about yours:
-What went wrong?
-How did you fix it?
-What do you do differently now?

Let’s share stories so others can avoid the same mistakes!

0 Upvotes

2 comments sorted by

2

u/Huggernaut 15d ago

For what it's worth, --force-with-lease is pretty much always what you want to use by default, since it will prevent pushing over remote commits your local clone is not aware of.

1

u/SeniorIdiot 15d ago

Why do people still do this? Just setup proper Rulesets that blocks force pushes on the default branch. Then add temporary exceptions when needed. And always use --force-with-lease. This is github 101.