.DS_Store 放入 gitignore 时不排除

.DS_Store not excluded when put in gitignore

我有一个 Java 应用程序,其中目录中存在一个 .DS_Store 文件,但我已将“.DS_Store”添加到 gitignore 中的一行,该行应排除此文件推送到 bitbucket 时的文件。但是,在 bitbucket 上我仍然可以看到 .DS_Store 文件——有人知道为什么会这样吗?

如果文件在 bitbucket 上,您在忽略它之前将其包含在之前的提交中。您需要删除它(在提交中)并将该提交推送到 bitbucket。