Someone ran `git push --force` to `main` and a day of other people's commits disappeared from the remote.
BeginnerTroubleshootingData loss and corruption
Answer
Likely causes → A force push replaced the remote branch with a local branch that didn't contain the newer commits. Branch protection wasn't on.
Diagnose → Find the commit main pointed at before the push: GitHub's activity view or the push event in the audit log, or any teammate's local clone (git reflog show origin/main), or the CI logs of the last build.
Fix →
git fetch origin
git push --force-with-lease origin <lost-sha>:main
Coordinate in the team channel so nobody pushes in the meantime, and ask people to rebase onto the restored main.
Prevent → Protect main: block force pushes and deletions, require PRs and status checks. Use --force-with-lease instead of --force on personal branches.
More on Data loss and corruption
An engineer ran `DELETE FROM orders;` on the production Postgres (forgot the `WHERE`) at 14:32.BeginnerA cleanup script deleted every object under `s3://acme-invoices/2025/`. Versioning is enabled.BeginnerYou need to restore last night's MySQL backup and discover the dump files for the past three months are 20 KB each.IntermediateUsers update their profile, the page reloads, and they see the old values; a minute later the new values show up.IntermediateA network partition between data centres lasted 4 minutes; afterwards you find both sites accepted writes as primary, and the same order IDs exist with different contents.AdvancedA deploy ran a migration that dropped the `phone` column; old pods still running during the rolling update threw 500s, and a background job wrote nulls into a new table.Intermediate