I am getting familiar with how the merge
command works and came upon the following unexpected case.
I noticed that trying to merge two commits, both of which edited a UTF-16 encoded file, Git failed to point out the changes made on both branches (the ones that are usually denoted with >>>>>> and <<<<<<). What it did is just leave the content of the version of the file that was under HEAD.
I tried to see the difference between them using the Git diff
command, but Git reported that it considers them as binary files instead of text files. I assume this could be the reason the merge didn't work as expected.
Note - Changing the default encoding of the edited file to UTF-8 solves both the problem with the diff
and with the merge
command.
Is there a way we can merge commits that have edited the same non-UTF-8 encoded file and ensure Git would indicate if, and in case - where exactly, conflicts occur?