20

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.

hs-
  • 176
  • 2
  • 5
  • 21
14wml
  • 4,048
  • 11
  • 49
  • 97
  • 1
    git merge abort works only during the merge not after. In example, when you have a conflict to resolve, you're in the middle of a merge and you could abort it. – alexscott Jan 06 '16 at 16:53
  • @alexscott oh okay thank you for the clarification! – 14wml Jan 06 '16 at 17:09

1 Answers1

21

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!

Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256