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
git log --onelineFind the commit that broke things and copy its hash.
git revert a1b2c3dCreates a new commit that undoes exactly that one. On a conflict: fix the file,
git addit, thengit revert --continue. For a merge commit, add-m 1.git pushShip the fix. A normal push, nothing is forced.
a1b2c3d is an example. Replace it with your own.
Before
After
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.