Utkarsh Gupta Utkarsh Gupta - 19 days ago 9
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:

*.pyc
.DS_Store
static/.DS_Store


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:

*/.DS_Store
**/.DS_Store
*DS_Store

Answer

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.

Comments