How to undo merge GIT with some conflicts, still not pushed?
Hello Guys, I have a small project with .Net Core and I used Git to manage source code. I have two branches, they are
Today I merged code from
uat branch. But I found some commits are not code done and I don't want to merge, I still do not push them.
You can see have 7 commits in the image below:
And I want to undo merge git, I checked on Visual Studio 2019 but it does not have any button to help revert it.
How can I undo it?
Gerardo Valle Feb 08 2022
Yeah, I undo merge git every day. You are merging code from
uatbranch and you still not push it, you can use the command below:
git reset --hard origin/uat
It really worked for me.
shruti sarva Feb 08 2022
You can refer to some ways below:
git reset --hard <commit_sha>
There's also another way:
git reset --hard HEAD~1
You also can use the
--mergeswitch instead of --hard since it doesn't reset files unnecessarily:
git reset --merge ORIG_HEAD
I hope it is useful for you.
* Type maximum 2000 characters.
* All comments have to wait approved before display.
* Please polite comment and respect questions and answers of others.