Answers for "how to undo merge commit in git"


git undo merge

git reset --hard HEAD~1
git reset --hard <commit_sha>
Posted by: Guest on March-05-2020

revert last merge git

git revert -m 1 commit_hash
Posted by: Guest on May-07-2020

how to reset last merge to previous commit git

//run git log
//output may look something like this:

Author: raybags <[email protected]>
Date:   Wed Jul 21 12:43:17 2021 +0200

    debugging redirects

commit 353f4990b4f7d310ff3d6bd79e736d22fda4add1
Author: raybags <[email protected]>
Date:   Tue Jul 20 21:26:59 2021 +0200

    impliment redirects for deployment

commit 216fa3a0b0c1c82cb415a317a16e2c232bdb6b84
Author: raybags <[email protected]>
Date:   Tue Jul 20 21:25:19 2021 +0200

//Select the "commit id" of the 2nd last commit your want to revert your master branch to
//i.e 353f4990b4f7d310ff3d6bd79e736d22fda4add1 (copy to clip bord)

//then run 

git reset --hard 353f4990b4f7d310ff3d6bd79e736d22fda4add1

This will reset your master branch to its prevous state discadding all recent changes.

Posted by: Guest on July-24-2021

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
Posted by: Guest on June-10-2021

Browse Popular Code Answers by Language