.DS_Store explained: what it is and how to handle it
The .DS_Store file is a Finder metadata container used by macOS to store folder view settings. It's harmless but can sneak into shared folders and version control. Here’s how to clean it up and prevent it from getting in
What is .DS_Store
The .DS_Store file (short for Desktop Services Store) is a hidden metadata file that macOS Finder creates in folders to remember how you like them displayed. It stores information such as icon positions, window size, toolbar layout, and the chosen folder background.
Why Finder creates it
Finder uses .DS_Store to restore your preferred viewing settings when you open a folder again. It is intended to improve your Finder experience on macOS.
Where you might see it
In Finder it’s hidden by default. If you enable viewing hidden files or if you share a folder with others, the file may appear as ".DS_Store" in that directory.
Why it can be a nuisance
When folders are shared, moved, or uploaded to cross-platform systems, .DS_Store files can clutter directories, bloat archives, and trigger unnecessary changes in version control. They do not contain user data from files themselves, just display metadata.
How to manage and remove .DS_Store
Removing
You can safely delete .DSStore files; Finder will recreate them as needed. In Terminal: find . -name ".DSStore" -type f -delete Or delete in a specific folder: rm /path/to/folder/.DS_Store
On macOS
To stop macOS from creating .DS_Store on network shares, you can use: defaults write com.apple.desktopservices DSDontWriteNetworkStores true Note: This affects network volumes and may not apply to local folders.
On Windows and Linux
Windows and Linux don’t use macOS Finder metadata, but .DS_Store can appear if you copy from a Mac. You can safely delete it, or exclude it from archives.
Global cleanup and automation
To prevent tracking in Git, add .DSStore to your global or per-repo ignore lists: git config --global core.excludesfile ~/.gitignoreglobal echo ".DSStore" >> ~/.gitignoreglobal You can also set up a recurring cleanup task or script to remove .DS_Store from projects.
Preventing future creation
Git and version control practices
Keep .DS_Store out of repositories with ignore rules; consider a per-repo .gitignore or a global excludes file.
Working with cross-platform directories
If you frequently move folders between macOS and other systems, maintain a standard cleanup protocol to keep the tree clean.
Quick tips for teams
- Treat .DS_Store as metadata only; it’s not part of your actual files.
- Include a clear policy for avoiding committing .DS_Store in shared repos.
- Consider automated checks during CI or pre-commit hooks to warn about or remove them.
Share This Article
Spread the word on social media
Anne Kanana
Comments
No comments yet. Be the first to share your thoughts!