Utkarsh Gupta Utkarsh Gupta - 10 months ago 66
Git Question

.gitignore not ignoring the sub-directory .DS_Store files

I tried everypossible solution I found here but none working. This is my .gitignore file:


It ignores .DS_Store files in the root directory of my repo but doesn't in the subdirectories like the directory named static. I even tried to add the follwoing in the .gitidnore files but they also don't work:


Answer Source

You need to remove the files in static/.DS_Store before the rules you have to .gitignore can take effect. Run this from the Git bash:

git rm -r --cached static/.DS_Store

This will delete these files from the repo, while retaining them on your local file system, which is what you want. After running this command, you should be able to see the delete changes by running git status.