0

I have a tracking branch to which I merged my master branch. There were conflicts that I fixed, committed and pushed. Now I need to revert that merge. How do I do it? I tried checking log, but obviously the history from master is now in the feature branch. Is there any hope?

1
  • 3
    There's always hope using source control. Commented Aug 14, 2013 at 17:04

2 Answers 2

1

From my understanding, it looks like you want to revert on your feature branch the merge commit that merged from your master branch.

You can do this in 2 ways, one which is more safe.

  1. git revert -m <parent_index> HEAD

To get the parent index, run git show <merge commit SHA1> and see the index (1-based) of the commit you want to revert to.

  1. git reset --hard <feature branch SHA1>

This isn't the better option because it resets your history and you won't be able to get back to the merge commit even if you wanted to.

I suggest using the first one because you get to keep track of the merge commit, in case you want to see how you merged something later on.

1
  • 1
    git show <merge commit SHA1> returns the same information set as git log. What I found confusing is the fact of two parent keys being present. In the end I have used git revert -m 1 <SHA of commit>. And I'm back to what I wanted. Commented Aug 15, 2013 at 15:32
0
git reset --hard <sha of last commit of feature branch>

We consider ur move is a merge commit. It will revert to feature branch and trash the merge commit.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.