Interview Prep/Git & GitHub/Undoing changes: reset, revert, restore and reflog

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.

All Git & GitHub questions Roadmap: Git & GitHub

More on Undoing changes: reset, revert, restore and reflog