← Back to all fixes
Need to undo a commit already pushed to main
The Issue
A bad change was pushed to main. Force-push is not allowed. Need to undo it safely.
Root Cause
The commit introduced a bug or broke production.
How to Fix
Use `git revert` — it creates a new commit that undoes the change, safe for shared branches`git revert <commit-sha>` — creates the inverse commitPush normally: `git push origin main`If the commit is a merge commit: `git revert -m 1 <merge-commit-sha>`Do NOT use `git reset --hard` on shared branches — it rewrites history and breaks other developers