0

Earlier I merged my feature branch in master which had a lot of commits and merging to master, created a merge commit in the master.

Later on, due to some issues, we had to revert the changes and this was done in another commit which says reverting merge commit of my feature branch.

Let suppose my merge commit is m and commit which reverted it is r.

Now again, I am starting my work on to resolve the issues which I had in my feature branch and I created a new feature branch from master and I want to get the code from my previous feature branch.

I tried doing cherry-pick but It gave me below error:-

error: commit is a merge but no -m option was given. fatal: cherry-pick failed.

I tried to do git merge <sha of my merge commit> in my feature branch but it says

Already up-to-date.

I read a lot of git tutorial and SO answers but couldn't get a clear understanding of what would be the best in my situation.

Let me know If any additional information is required.

Amit
  • 30,756
  • 6
  • 57
  • 88

1 Answers1

0

The simplest solution: Revert the revert commit r :-)

A.H.
  • 63,967
  • 15
  • 92
  • 126
  • I need to do this in another feature branch. – Amit Jan 05 '19 at 13:36
  • You can do this in another branch as long as the commit `r` is an ancestor of the new branch. – A.H. Jan 05 '19 at 14:00
  • @A.H. the commit need not even have any ancestor/descendant relationship: `git revert` is implemented internally as a merge, with the commit being reverted as the merge base, its parent as the other-branch tip, and the current commit as the current commit. (This one is a fair bit weird to get one's head around! It's easier to think about it as "reverse-apply the commit's changeset", which produces the same result in many cases.) – torek Jan 05 '19 at 15:16