Written by me@grafxflow
It's very annoying under macOS when creating a new repo we occasionally see the dreaded .DS_Store files appear. So here is how to remove those annoying Mac OS X .DS_Store files from a Git repository.
First remove the existing .DS_Store files from the repository:
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
Then add this line:
.DS_Store
to the file .gitignore, which can be found at the top level of your repository (or create the file if it isn't there already). 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
All done.
Founder, Grafxflow
I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. I build lighting-fast dynamic content engines with Laravel, Winter CMS and Tailwind CSS. Thanks for stopping by!