If you have ever opened a shared ZIP file, cloned a Git repository, or plugged in an external drive and spotted a file called .DS_Store, you are not alone. These files appear in virtually every folder on a Mac, they travel with your files to other people's machines, and they occasionally trigger security warnings or clutter Git history. This guide explains exactly what .DS_Store is, why macOS creates it, why it ends up places it should not, and what you can safely do about it.
What Is .DS_Store?
.DS_Store stands for Desktop Services Store. It is a hidden metadata file that macOS Finder writes into nearly every folder you open. The file stores Finder-specific view preferences for that particular folder, including:
- Icon positions (if you have arranged icons manually)
- The selected view mode: icon, list, column, or gallery
- Window size and scroll position for that folder
- Background color or image set via View > Show View Options
- Sort order overrides
- Tags and label colors applied to items in that folder
Every time you open a folder in Finder, macOS checks for a .DS_Store file and reads its preferences. If one does not exist yet, Finder creates it. If you change the view, Finder updates it. This happens silently in the background.
Because the filename begins with a period, it is treated as a hidden file on Unix-based systems including macOS and Linux. You will not see it in a standard Finder window, but it is there. To reveal hidden files in Finder, press Command + Shift + . (period) in any folder.
Why Does macOS Create .DS_Store Files?
The .DS_Store file format dates back to Mac OS X 10.0. Apple's design decision was to store folder view metadata inside the folder itself rather than in a central database. The reasoning is straightforward: if you copy a folder to a different Mac or an external drive, the view preferences travel with it. Open that folder on the new machine and your carefully arranged icon grid is still intact.
This approach works well within the Apple ecosystem. The problems start when those folders leave the Apple ecosystem entirely.
Why .DS_Store Shows Up in Git Repos and Shared Drives
The .DS_Store file meaning changes depending on who is receiving it. For other Mac users on your team it is harmless noise. For Linux or Windows users it is a mysterious file that serves no purpose on their system. For Git repositories, it can actively cause problems.
The Git problem
When you run git add . without a .gitignore in place, Git happily stages every .DS_Store it finds. These files then appear in commit history, show up in diffs, and get pushed to remote repositories like GitHub or GitLab. Anyone who clones the repo gets your personal folder preferences baked into the project. Over a long-lived repo with many contributors, dozens of .DS_Store commits can accumulate.
The standard fix is a project-level or global .gitignore entry:
# In your project's .gitignore
.DS_Store
# Or recursively for nested folders
**/.DS_Store
To set a global Git ignore that covers every repo on your machine, run:
echo ".DS_Store" >> ~/.gitignore_global
git config --global core.excludesFile ~/.gitignore_global
If .DS_Store files have already been committed to a repository, you can remove them from tracking without deleting the actual files:
find . -name .DS_Store -print0 | xargs -0 git rm --cached --ignore-unmatch
git commit -m "Remove .DS_Store files from tracking"
Shared drives and ZIP archives
When you compress a folder using Finder's Compress option, the resulting ZIP includes every hidden file in that folder, including .DS_Store. Recipients on Windows see an extra file they did not ask for. Network shares (SMB, NFS, Dropbox) also propagate .DS_Store to shared folders where other operating systems have no use for them.
For ZIP archives, you can compress from Terminal to exclude hidden files:
zip -r archive.zip my-folder/ -x "*/\.*"
Is Deleting .DS_Store Safe?
Yes, deleting .DS_Store files is completely safe. These files contain nothing important to you or your applications. The only consequence is that Finder forgets any custom icon positions or view preferences you had set for affected folders. For most folders, that means no visible change at all because most people never manually arrange icons or set custom backgrounds.
macOS will recreate .DS_Store in any folder the next time Finder opens it, so deletion is not permanent. It is more of a cleanup step than a permanent removal.
How to Delete .DS_Store Files on Mac
Delete from a specific folder
Open Terminal and navigate to the folder you want to clean, then run:
find ~/Documents -name ".DS_Store" -delete
Replace ~/Documents with any path, or use . to target the current directory.
Delete from your entire home folder
find ~ -name ".DS_Store" -delete 2>/dev/null
The 2>/dev/null suppresses permission errors for folders you cannot read.
Delete from an external drive before sharing
find /Volumes/MyDrive -name ".DS_Store" -delete
Replace MyDrive with your drive's actual name as it appears in Finder.
Can You Stop macOS From Creating .DS_Store on Network Drives?
macOS includes a defaults setting that prevents Finder from writing .DS_Store to network volumes. This is useful for team SMB shares. Run this command and then log out and back in (or restart Finder):
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
To reverse it:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool FALSE
Note that this only affects network drives. Finder will continue writing .DS_Store on local volumes and external drives attached directly to the Mac.
There is no supported system setting to stop Finder from creating .DS_Store on local drives entirely. Third-party approaches exist but can interfere with Finder's view memory in ways that become annoying quickly. For most users the practical answer is: ignore them on local drives, exclude them from Git with .gitignore, and delete them before sharing folders externally.
How Much Space Do .DS_Store Files Actually Use?
Individually, .DS_Store files are tiny, typically between 6 KB and 20 KB each. On a well-used Mac with thousands of folders, the combined total might reach a few megabytes. That is not the reason to clean them. The reason is tidiness, especially before sharing projects, uploading to version control, or archiving folders for backup.
Where .DS_Store matters for storage is as a symptom. When a disk cleaner scans your Mac and surfaces hidden files, .DS_Store entries scattered across /Users/yourname, ~/Desktop, ~/Downloads, and mounted drives are a normal and expected finding. They belong in the "safe to remove" category.
What About .DS_Store in iCloud Drive and Dropbox?
Both iCloud Drive and Dropbox sync hidden files including .DS_Store. This means your Finder view preferences for a folder can sync across your own Macs, which is actually useful. The downside is that shared Dropbox folders expose your .DS_Store files to other collaborators. Dropbox has historically filtered these on their end for some shared scenarios, but it is not guaranteed. The safest habit for shared Dropbox folders is to periodically clean them with the find command above.
If you want to skip the Terminal entirely, Crumb auto-detects .DS_Store files during a disk scan and flags them as safe junk you can review and remove in one step, alongside caches, app leftovers, and other clutter that accumulates on macOS over time. Everything runs on-device and no account is required.