0

The problem is: we want to merge topic into master, but topic is an ancestor of master, so the merge is a no-op. A commit between topic and master had reverted the previous merge of topic into master. It did that using reset not revert. Now, a diff between master..topic shows all the changes that we want to apply. How do we apply those changes?

       C      B      A      D
master * ---- * ---- * ---- * ---- * 
                       \ 
                        \
                   topic * ---- * ---- * ---- * 
  • A was a merge.
  • B reverted both A and D but without using revert.
  • C added additional commits

Edit:

B reverted more than A, but we want to re-apply only the changes that A introduced. Therefore, reverting B will not accomplish our goal, because it will restore D.

Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467

2 Answers2

3

There are some options:

  1. You can revert B and revert D. Reverting B will restore D, so you revert D again.

  2. If the diff is showing just what you want to apply, you can create a patch file from the diff and apply that patch file in the master branch.

Create the patch:

git diff master..topic > file.patch

Go to master and apply the patch:

git apply file.patch
Fede
  • 460
  • 3
  • 10
0

Look at:

Re-doing a reverted merge in Git

Short answer: revert the revert. but there are gotchas you should look at in the git documentation

Jeff Wang
  • 1,837
  • 1
  • 15
  • 29