There's no need to revert anything here. You almost had the right solution, but your reset to the incorrect commit. The way to fix this is to run:
git reset --hard <pre-merge commit hash>
This will reset your master branch to the commit prior to the merge. From here, you can run:
git push origin master --force
to reset your remote master branch as you had done before. The command that you ran erroneously pointed the master branch to the merge commit hash.
For your own background knowledge, if you take a look in .git/refs/heads
you'll see a list of files with the same names as your branches. The contents of these files are just the hashes of each of the commits that they point to. And that's literally all a branch is: a reference to a commit.
When you ran git reset --hard <merge commit hash>
, you made the master branch (which is just this very simple reference file) point to the merge commit. By pointing it to the commit before the merge, you'll update this simple master branch reference to point to the hash of the commit before the merge.