如何忽略Git上的IDE设置?

Cat*_*ysm 6 eclipse git

我有以下Git信息,我想忽略我的IDE(Eclipse)的设置.

modified:   myproject/.classpath
modified:   myproject/.project
modified:   myproject/.settings/com.google.gdt.eclipse.core.prefs
modified:   myproject/.settings/org.eclipse.core.resources.prefs
modified:   myproject/.settings/org.eclipse.jdt.core.prefs
modified:   myproject/.settings/org.eclipse.wst.common.component
modified:   myproject/.settings/org.eclipse.wst.common.project.facet.core.xml
modified:   myproject/.settings/org.eclipse.wst.validation.prefs
Run Code Online (Sandbox Code Playgroud)

我在我的.gitignore文件中尝试了以下语句,但它不适用于这些设置:

.project
.classpath
.settings
*.project
*.classpath
*.settings
/.project
/.classpath
/.settings
.project/
.classpath/
.settings/
*.project/
*.classpath/
*.settings/
Run Code Online (Sandbox Code Playgroud)

我使用的是Mac OS X,我还使用这些设置添加了全局gitignore文件git config --global core.excludesfile '~/.gitignore',但是当我查看时,我仍然会收到上面的Git更新消息git status.我错了什么?

Von*_*onC 18

如果这些元素已经提交,则需要先删除它们:

git rm --cached .project
git rm --cached .classpath
git rm --cached -r .settings
Run Code Online (Sandbox Code Playgroud)

--cached选项允许他们留在工作树中,同时记录删除.
删除后,它们将被忽略.

一旦提交,下一个更改将被忽略.

一个简单.gitignoremyproject/文件夹就足够了:

.project
.classpath
.settings/
Run Code Online (Sandbox Code Playgroud)

请注意/for .setting文件夹:它将忽略其中的所有内容.