What is the safest way to undo a pushed commit that exposed a bug?
IntermediateConceptUndoing changes: reset, revert, restore and reflog
Answer
git revert <sha> on the shared branch, open a PR, merge. History stays append-only so no one needs to re-sync. If the bad commit is a merge, add -m 1. Rewriting main with reset --hard plus a force-push should be reserved for secret leaks and done with team coordination.
More on Undoing changes: reset, revert, restore and reflog
What are the three modes of `git reset`?BeginnerWhat is the difference between `git reset` and `git revert`?BeginnerHow do you discard changes in one file?BeginnerHow do you recover a commit after `git reset --hard`?IntermediateCan you recover uncommitted changes lost by `git reset --hard` or `git checkout .`?IntermediateWhat does `git commit --amend` do to the reflog and to the old commit?Intermediate