git reports merge conflict although files are the same

116 views Asked by At

I have a master branch and development/Server branch in git. I created Pull Request and trying to merge development/Server to master branch but I am facing conflict. I am getting conflicts for 2 files: .h and .cpp "This pull request can't be merged. You will need to resolve conflicts to be able to merge"

git merge also didn't pass.

When I compare those two files I can see that they are iddentical. Tried it manually and I also checked on online comparison tools (e.g. codebeautify)

Why git reports conflicts although files are identical???

Please give me any hints you might have, I really can't find the solution for this.

Thanks a lot!!!

1

There are 1 answers

1
knittl On BEST ANSWER

There are different reasons why a path can be conflicted during merge:

  • Both sides of the merge make incompatible textual changes (e.g. change the same line).
  • Both sides added a file under the same path with different content.
  • One side added a file, the other side added a directory.
  • One side changed the file, the other side removed the file.
  • The permissions (mode) of the path are incompatible, e.g. one side of the merge adds an executable file, while the second side adds a non-executable file under the same path.

git status will tell you which paths are conflicted and which kind of conflict it is.

git diff will show you the conflicting changes.

Resolve the conflicts and git add the file with the desired content or permissions, then git commit the merge.