Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo merge of master branch? [duplicate]

I'm new Github so please forgive what may seem like an obvious question. I have an Experimentation branch which is 24 commits ahead of the master branch.

Following this tutorial, I merged the master branch with the Experimentation branch like so:

git checkout master
git merge Experimentation

(There were no merge conflicts.)

But then I realized that merging the two branches would not keep the commit history of the Experimentation branch and what I really wanted was to do a rebase (in order to keep the commit history of the Experimentation branch).

So my question is: how do I undo the merge of the master branch?

I've already tried:

$ git branch
      Experimentation
    * master
      pod-attempt

$ git merge --abort
      fatal: There is no merge to abort (MERGE_HEAD missing).

The "fatal" message confused me b/c I thought I did merge the master branch.

like image 636
14wml Avatar asked Jan 06 '16 16:01

14wml


1 Answers

There is no ongoing merge pending so git is supposed to show you,

fatal: There is no merge to abort (MERGE_HEAD missing).

Now if you want to go back to previous state (state before you merged), try

$ git branch
      Experimentation
    * master
      pod-attempt
$ git reset --hard HEAD~24

You are done!

like image 175
Sazzad Hissain Khan Avatar answered Sep 19 '22 14:09

Sazzad Hissain Khan