Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github: Changes ignored after revert (git cherrypick, git rebase)

Tags:

git

github

Lets say I have two branches A and B

(A)--------(A+B)--------------(A+B+R)
 \        / merge   \ revert  /
  \      /           \       /
 (B)----(B+)         (R)----

First, I merged branch B to A, Then I reverted the merge request with GitHub's revert feature.

Now when I fix some code on branch B and need to merge to A again, almost all changes (except the new one that I fix) are ignored. How can I get the changes again?

like image 641
Wendy Adi Avatar asked Dec 15 '22 08:12

Wendy Adi


1 Answers

You need to revert the revert, i.e. revert the commit that your previous revert created.

The reason for this is that a merge really does 2 things: it changes the file contents to reflect the merge, and also creates a commit with 2 parents to tell git what was merged. When you revert, it undoes the first thing, but not the second. So when you try to re-do the merge, git has no idea that you reverted the previous merge, so it ignores everything before then.

like image 70
David Deutsch Avatar answered Apr 19 '23 23:04

David Deutsch