revert a merge git code example

Example 1: undo a git merge

git reset --hard HEAD~1
git reset --hard <commit_sha>

Example 2: git revert merge

git revert -m 1 <merge-commit>

Example 3: git undo merge

git reset --hard HEAD~1

Example 4: git revert pr merge

git revert -m 1 b76a5f1f5d3b323679e466a1a1d5f93c8828b269 (Commit Number)

Example 5: undo merge

// find the commit hash
git log --oneline

git revert -m 1 [commit-hash]

// https://www.datree.io/resources/git-undo-merge

Example 6: git revert merge commit

// In this situation, will get you the tree as it was in 8989ee0
git revert <commit hash> -m 1 

//will reinstate the tree as it was in 7c6b236
git revert -m 2