I was doing some refactoring on another branch and moved some methods in different place in the same file.
Then, after merge to master, git did not remove the old placement, and imported the new methods in new location. As a result I got a new file with some methods duplicated (also some code blocks were messed up).
It looks like git treated the new methods as a PHPDoc comments.
Is there any chance to avoid such a behavior in the future?
(Im using git for development with Zend Framework, the code is formatted using ZF coding standard)
Git does not know about PHPDoc comments, as it happily ignores the content of the files (well except for the evil CR/LF issue).
It looks to me you did not add all the files or one of your colleagues triggered a change in the lines in question.
Check with git log if all files with changes were actually committed. With git diff you can check the differences between the commits to figure out exactly where it went pear shaped.