How to undo merge GIT with some conflicts, still not pushed?

Dung Do Tien Feb 08 2022 42

Hello Guys, I have a small project with .Net Core and I used Git to manage source code. I have two branches, they are beta and uat

Today I merged code from beta into 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:

How to undo merge GIT with some conflicts, still not pushed?

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?

Have 2 answer(s) found.
  • G

    Gerardo Valle Feb 08 2022

    Yeah, I undo merge git every day. You are merging code from beta to uat branch and you still not push it, you can use the command below:

    git reset --hard origin/uat

    It really worked for me.

  • s

    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 --merge switch instead of --hard since it doesn't reset files unnecessarily:

    git reset --merge ORIG_HEAD

    I hope it is useful for you.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close