All fixes

Help, I pushed a commit that broke everything

Undo one pushed commit safely with git revert, without rewriting history your team already pulled.

The fix

  1. git log --oneline

    Find the commit that broke things and copy its hash.

  2. git revert a1b2c3d

    Creates a new commit that undoes exactly that one. On a conflict: fix the file, git add it, then git revert --continue. For a merge commit, add -m 1.

  3. git push

    Ship the fix. A normal push, nothing is forced.

a1b2c3d is an example. Replace it with your own.

What happens to your history
BeforeABCDHEADmain
AfterABCD−BHEADmain

Why this works

revert does not delete anything. It creates a new commit that does the exact opposite of the bad one, so everyone can simply pull it. That makes it the right undo for anything that is already shared. You can revert any commit, not just the last one. And if you need the change again later, revert the revert.