0

I am using git. I have 3 branches master(m), feature1(f1) and feature2(f2).

--------------------- m
       |       |
       |         ------- f1
         ------------- f2

I have merge f1 into f2. and then reverted the merge and later merge f2 to master, now master have commit for merging f1 and reverting the f1 merge.

Now i want to get the latest changes from the master so want to merge master to f1, but when i tried to merge it removed all my previous changes. Is there a way to merge master to my feature1(f1) without the merge revert commit.

shubham garg
  • 105
  • 8
  • You can do that with an interactive rebase, but I think your safest bet would be to `git revert` the revert commit. – Madara's Ghost May 10 '16 at 07:18
  • so i should first merge the master to my feature app, then on it revert the revert commit – shubham garg May 10 '16 at 07:21
  • Yes. See if that does it. I'd also create new branches at the tips of each branch, so that I can return things to how they are now, regardless of what you do. That's especially helpful with actions like rebase which are destructive, history changing actions. – Madara's Ghost May 10 '16 at 07:22
  • Thanks, it worked, i just reverted the revert merge commit. You can add your answer, i will accept it :) – shubham garg May 10 '16 at 07:34

1 Answers1

2

When reverting a merge commit those changes will never be made available in any subsequent merge as the revert prevents any ancestors being included in the merge.

You can overcome this by reverting the revert commit on the f1 branch after merging master. Don't revert on master as you'll have the f1 changes in master before the merge into f1 which I'm guessing you don't want.

Darren Lewis
  • 8,338
  • 3
  • 35
  • 55