使用PHPStorm,我试图忽略workspace.xml,每次我尝试进行git提交时,它都会弹出。

我的。gitignore看起来像:

/.idea/
.idea/workspace.xml

因为在提交文件时,我还执行了:

Git rm——缓存。idea/workspace.xml,然后提交删除,推到一个裸repo。

但是当我在项目中进行更改时,该文件一直弹出。

你知道我错过了什么吗?


当前回答

如果你的git repo中有多个项目,.idea/workspace.xml将不匹配任何文件。

相反,你可以这样做:

$ git rm -f **/.idea/workspace.xml

让你的。gitignore看起来像这样:

# User-specific stuff:
**/.idea/workspace.xml
**/.idea/tasks.xml
**/.idea/dictionaries
**/.idea/vcs.xml
**/.idea/jsLibraryMappings.xml

# Sensitive or high-churn files:
**/.idea/dataSources.ids
**/.idea/dataSources.xml
**/.idea/dataSources.local.xml
**/.idea/sqlDataSources.xml
**/.idea/dynamic.xml
**/.idea/uiDesigner.xml

## File-based project format:
*.iws

# IntelliJ
/out/

其他回答

我刚才遇到了这个问题,我必须做git rm -f .idea/workspace.xml 现在它似乎不见了(我也不得不把它放进。gitignore)

忽略以.iws结尾的文件,以及.gitignore中的workspace.xml和tasks.xml文件 参考

我在基于IntelliJ的Android Studio中所做的是这样的。在提交对话框中,我恢复了对workspace.xml的更改,然后将其移动到未版本控制的文件。之后,我从提交对话框中删除了这个。现在它不会出现在更改列表中。注意,我的gitignore已经包含了.idea/workspace.xml

因为在我的情况下,我执行一个项目的第一次提交,简单地删除。git和。idea文件夹,然后使用git init重新初始化git有助于解决问题。现在我完全不知道了。

只是想分享一下我的经验。

无论我尝试什么,我都有同样的问题,但我正在进行的回收如你所期望的那样在顶层生成了一个.idea,但.gitignore被放置在目录树下的一个文件夹中。

So:

.idea // On the level above the .gitignore file
application/
- .gitignore // too low to include .idea
- otherfile.js

所以我的解决方案是,我需要在repo的顶层创建一个.gitignore文件,然后我可以像预期的那样删除/ .idea文件夹,就像这样:

.gitignore // Now this can successfully target .idea below
.idea
application/
- .gitignore
- otherfile.js