Issue
I have below Git information and I would like to ignore settings of my 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
I tried the below statements in my .gitignore
file, but it doesn't work for these settings:
.project
.classpath
.settings
*.project
*.classpath
*.settings
/.project
/.classpath
/.settings
.project/
.classpath/
.settings/
*.project/
*.classpath/
*.settings/
I am using Mac OS X and I also added global gitignore file with these settings git config --global core.excludesfile '~/.gitignore'
, but I'm still getting the above Git update messages when I check with git status
. What am I wrong?
Solution
If those elements were already committed, you need to remove them first:
git rm --cached .project
git rm --cached .classpath
git rm --cached -r .settings
The --cached
option allows them to stay in the working tree, while being recorded for deletion.
Once deleted, they will be ignored.
Once committed, the next changes will be ignored.
A simple .gitignore
in myproject/
folder is enough:
.project
.classpath
.settings/
Note the /
for .setting
folder: that will ignore everything in it.
Answered By - VonC
Answer Checked By - Cary Denson (JavaFixing Admin)