cancel a merge git

C++
git reset --hard HEAD~1
git reset --hard <commit_sha>git merge --abort
Source

Also in C++: