在 Git 中隐藏跟踪区域中的文件

Hide file from tacking area in Git

我无法通过 git status 命令隐藏特殊文件

例如,我不想在我的项目中有phpstorm.php,我将其添加到git忽略

但是当我使用 git 状态命令时,显示的消息如下:

未跟踪的文件: (使用“git add ...”来包含要提交的内容) phpstorm.php

实际上,我想要 phpstorm.php 但隐藏 git 状态

谢谢

在您的 .gitignore 文件中添加 /phpstorm.phpphpstorm.php 作为一行。

/phpstorm.php.gitignore.

匹配同一文件夹的 phpstorm.php 文件

phpstorm.php 匹配所有文件,例如包括 someFolder/phpstorm.php.

有关详细信息,请参阅 gitignore Documentation