在PhpStorm中修改文件会导致Git将文件视为“已修改”即使在撤消更改之后 [英] Modifying a file in PhpStorm causes Git to consider a file as "Modified" even after undoing the changes

查看:1528
本文介绍了在PhpStorm中修改文件会导致Git将文件视为“已修改”即使在撤消更改之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来,当我在PhpStorm中修改一个与git项目不同的文件时,即使在所有更改恢复后(或者 Ctrl + Z 或手动撤消它们,它都会将该文件标记为已修改)。这似乎是特定于PhpStorm,并且即使我在PhpStorm项目中禁用了VCS也是如此。



显然PhpStorm正在做一些事情,试图弄清楚。

我已经检查了工作树对索引和行结束符之外的情况,所有内容都精确到文件的mtime和ctime。我附上了两个屏幕截图,第一个是在PhpStorm中进行更改和撤消,第二个是通过Visual Studio Code。我标记了我进行更改(1)并回复更改(2)的要点。我也尝试使用



Visual Studio代码



任何人都可以建议什么时候使用Git功能(如果有的话),当我通过不是通过VSCode发生的PhpStorm进行更改时?或者可能是找出为什么Git认为文件已被修改,尽管通过PhpStorm恢复了所有更改的原因。



在PhpStorm论坛上发布交叉帖子:



https://intellij-support.jetbrains.com/hc/en-us/community / posts / 115000590464-Modifying-a-file-in-PHPStorm-causes-Git-to-consider-a-file-as-Modified-after-after-undoing-the-changes

解决方案使用命令 git status -vv ,我可以看到文件在我使用PHPStorm时正在更改。由于PHPStorm中的安全写入设置,权限发生了变化。一旦我禁用了它,一切都按预期工作。

另外,我之前误解了运行命令 git ls- files --eol --stage --debug app / socrates / ajaxphp / ajaxFUChangeStatus.php 。运行该命令时,它只显示缓存文件的ctime和mtime(IE:git索引/分段文件)。当确定文件是否被修改时,Git会将这些值与 stat< file> 的结果进行比较(这将是您的工作树)。我只是想澄清,所以没有人被误导。

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.

PhpStorm:

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 PhpStorm forums:

https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000590464-Modifying-a-file-in-PHPStorm-causes-Git-to-consider-a-file-as-Modified-even-after-undoing-the-changes

解决方案

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 was misled.

这篇关于在PhpStorm中修改文件会导致Git将文件视为“已修改”即使在撤消更改之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆