'Git detects files as newer after reverting a merge, so it doesn't show conflict

I have this scenario: There are 2 branches, 'develop' and 'feature-branch'. This two branches have been growing over time each one independently. Now, 16 of November of last year, a merge was done from 'feature-branch' to 'develop'. This merge should not have been done so it was reverted on 19 of November. The problem: now the files in develop are newer, so when doing a merge from 'develop' to the branch to integrate both, git keeps the files in develop. This is a problem because there is code on the branch which is necessary, and since it doesn't create conflicts, I'm not able to integrate them. I would need to manually check every file and check the logic, which is not ideal. Is there any way of fixing this?



Solution 1:[1]

  1. Checkout a new local branch called 'prepare-develop-for-merge-into-feature-branch' based on the merge-revert commit of 'develop'.
    git checkout -b prepare-develop-into-feature-branch <commit-id-of-merge-revert>
  2. Create a commit that reverts the merge-revert
    git revert HEAD
  3. Checkout 'feature-branch'
    git checkout feature-branch
  4. Merge 'prepare-develop-for-merge-into-feature-branch' into it
    git merge prepare-develop-for-merge-into-feature-branch
  5. Merge actual 'develop' into 'feature-branch'
    git merge develop

The result should then look like what you'd expect it to look if that merge-revert never happened.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jay