'How to undo a merge in GitHub

I have been working in PhpStorm on a dedicated branch, but when pushing to github, I inadvertently merged to the master branch.

How would I undo the merge both in github and locally? The github master is used to migrate code to various servers so I need to rollback to the previous commit prior to the merge rather than create a new commit with my changes undone.



Solution 1:[1]

To answer this more succinctly:

git checkout master
git reset --hard <commit_before_merge>
git push -f

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John Doherty