Modifying a file in PHPStorm causes Git to consider a file as “Modified” even after undoing the changes

It seems when I modify a file in PHPStorm which is apart of a git project, it marks the file as modified even after all changes have been reverted (either CTRL+Z or by manually undoing them). This seems to be specific to PHPStorm and occurs even if I have VCS disabled for the project in PHPStorm.

It's apparent PHPStorm is doing something under the covers which is what I'm trying to figure out.

I've checked the working tree against the index and outside of line endings, everything is exact down to the mtime and ctime for the file. I attached two screenshots, the first is making the change and undoing it in PHPStorm and the second is via Visual Studio Code. I marked the points where I made the change (1) and reverted the change (2). I've also tried using git diff to try to find out what Git thinks is different, but it comes up with nothing every time.



Visual Studio Code:

Can anyone suggest what Git functionality is being used (if any) when I'm making changes via PHPStorm which isn't occurring via VSCode? Or possibly a way to figure out why Git thinks the file has been modified despite all changes being reverted via PHPStorm.

Cross post on SO:


By using the command git status -vv I was able to see that the permissions on the file were being changed whenever I used PHPStorm. The permissions were changed because of the Safe Write setting in PHPStorm. Once I disabled this, everything worked as expected.

Additionally, I previously misunderstood the significance of the mtime and ctime when running the command 

git ls-files --eol --stage --debug app/socrates/ajaxphp/ajaxFUChangeStatus.php.

When running that command, it only displays the ctime and mtime of the cached file (IE: the git index/staged files). Git compares those values with the result of 

stat <file> 

(which would be your working-tree) when determining if a file has been modified. I just wanted to clarify so no one reading this is misled.


Thanks for the comment


Please sign in to leave a comment.