Your destination for complete Tech news

How to undo a git merge that hasn’t been pushed to remote

1.79K 0
< 1 min read

There may be certain situations when you do the changes and merge the working branch on the master branch. Later on, you realize that you missed something on the commit and you want to make those changes on the same commit. You can revert the git merge by following ways.

The condition here is you have not pushed to the remote master branch.

You can revert the merge by finding out the commit prior to the merge by doing “git reflog”.

Then do the following

git reset --hard commit_hash

You can also use the following way which will get you back to 1 commit

git reset --hard HEAD~1

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.