A normal non-merge commit caused a regression on a shared branch. Other developers have already pulled it. How can its changes be reversed without rewriting their shared history, and how should conflicts be handled?
Editorial starter question from DevCircle, provided for learning and discussion.
Use git revert to create a new commit reversing the selected change. Start with a clean working tree and identify the exact commit.
bash
git status
git log --oneline -8
git revert <commit-sha>
Review the diff and run relevant checks before pushing through the normal review process. If conflicts occur, resolve and stage the files, then run git revert --continue. Use git revert --abort to abandon the operation. Revert preserves existing history; reset followed by a force-push rewrites a branch others may depend on. Merge commits require an explicit mainline-parent decision and should not use this normal-commit recipe blindly.