DS_Store files are automatically created by Mac OS X Finder in browsed directories. These files contain information about system configuration. If you upload them along with other files, the files can be misused to obtain information about your computer. For more information, see Apple security updates.
Sometimes it is annoying to see .DS_Store files added to your git repositories. Every time you do git status you may suddenly find new .DS_Store file in your git repository tree. So how to remove these git .DS_Store files and make your git repo not track them?
How to remove DS_Store files from tracking
First of all, lets remove existing DS_Store files from the repository:
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
Next, add the following line to your .gitignore file, which can be found at the top level of your repository. (Or create the file if it isn’t there already):
.DS_Store
You can do this easily with this command in the top directory:
echo .DS_Store >> .gitignore
Then commit the file to the repo:
git add .gitignore git commit -m '.DS_Store banished!'