I understand the two files are exactly the same in your situation, thus the patch is likely to succeed.
However, in case you want to apply a patch to a similar, but not exactly the same file, or you want to do an interactive patching, you will use three way merge.
Say you modified File A
, let's denote A~1
as the previous version, and you want to apply the diff between A~1
to A
to File B
.
Open a three way merge tool, for instance Beyond Compare, the path of left panel is A
, middle panel is the common ancestor so the path is A~1
, the path of right panel is B
. Then, the lower panel shows the result of applying the diff between A~1
to A
to File B
.
The following figure illustrates the idea.