0

I have a branch that had some work on it, then it was merged into the main branch. Immediately after this, the merge has been reverted. I continued to work on my branch and the main branch also had changes. Now I need to merge those changes from the main branch to mine, but because of the former revert, some of my changes are removed. Of course I can add them manually, but there must be a "proper" way. Could you please help me?

A----B---D-X---E---G--I
 \---C--/------F---H---\J

So my branch started from commit A, then I added commit C. Then it was merged into master branch with commit D, then reverted with X. Now when I merge the master to mine in commit J, I have all my changes in commit C removed.

Moha
  • 857
  • 2
  • 12
  • 25
  • 1
    Revert the revert. The merge result is "correct" (by Git's definition) because the earlier revert is *part of the work being merged*. If you want to undo that, undo the revert, by reverting it. You can do this before or after merging. – torek Jun 25 '21 at 08:43
  • Can I revert the main branches revert on my branch after the merge? How? – Moha Jun 25 '21 at 08:51
  • 3
    See [How do I "un-revert" a reverted Git commit?](https://stackoverflow.com/questions/8728093/how-do-i-un-revert-a-reverted-git-commit) and [Re-doing a reverted merge in Git](https://stackoverflow.com/questions/1078146/re-doing-a-reverted-merge-in-git) and many others. – IMSoP Jun 25 '21 at 08:57
  • Managed to solve it by merging the main branch to mine then reverted the revert on it. – Moha Jun 25 '21 at 14:30

0 Answers0