By Joel Dare - Written September 7, 2025
MacOS has a nasty habit of creating .DS_Store
files randomly. I always want to ignore these files. I do that with these two simple steps.
Run the following command to create a global git ignore file.
git config --global core.excludesfile ~/.gitignore
Add .DS_Store
to it.
echo .DS_Store >> ~/.gitignore
The .DS_Store file, short for Desktop Services Store, is macOS Finder’s way of remembering how you like to view a folder. It stores things like icon positions, thumbnail sizes, custom backgrounds, window dimensions, and sort order. Each directory you open in Finder gets its own hidden .DS_Store
, and the behavior goes all the way back to the first releases of Mac OS X in 2001, when Apple rebuilt the system on top of Unix but wanted to preserve the classic Mac habit of remembering folder views.
It became infamous because Finder didn’t just write these files locally — it left them behind on network shares, external drives, and even inside ZIP archives. To Windows and Linux users, the files looked like litter. To developers, they showed up in Git repositories where they served no purpose and often caused annoying merge conflicts. Apple eventually provided an option to suppress .DS_Store creation on network volumes, but the files are still written on local drives and removable media.
Some reports say this is a bug, others say it’s not.
Want to build your next site in pure HTML and CSS? Join the free Five-Day Neat Starter Email Course and build a lean, production-ready page before Friday.
JoelDare.com © Dare Companies Dotcom LLC