Just reset HEAD for the previous commit:
git reset
You do not state in your question if you pushed your erroneous merger or not, so you need to click with -force if that is the case (since you rewrote the story on the main branch).
Please note that rewriting history can cause problems for other developers if they based their work on erroneous commit. In this case, you might think:
git revert HEAD
However, this will create a new commit, which makes the opposite commit that HEAD is pointing to right now, and ruin the repository. Resetting is better in this sense, since you are getting rid of two commits, one of them is faulty and one to compensate for the malfunction.
source share