If you have ever opened a shared folder or pushed a project to GitHub and noticed a mysterious file called .DS_Store, you are not alone. Understanding what .DS_Store is, why macOS creates one in virtually every folder you touch, and whether you should bother removing it will save you a lot of confusion — and the occasional embarrassing commit.
What Is .DS_Store?
The name stands for Desktop Services Store. It is a hidden metadata file that macOS Finder creates automatically whenever you open a folder in Finder — even briefly. The file lives inside that folder and stores Finder-specific display preferences for it, such as:
- The icon positions if you arranged items manually in icon view
- The current view mode (icon, list, column, or gallery)
- The folder background color or image, if you set one
- Column widths in list view
- Whether the toolbar and sidebar were visible the last time you opened that window
- Spotlight comment metadata attached to files in that folder
In other words, .DS_Store is Finder's personal notebook for each directory. It has nothing to do with your actual files and contains no user data beyond folder-display preferences.
Why Does macOS Create .DS_Store Files Everywhere?
Finder writes or updates a .DS_Store file the moment it reads a directory — even if you change nothing. Open your Downloads folder, close it, and a .DS_Store file either appears or gets updated. This happens because Finder eagerly persists view state so that each folder looks exactly the way you left it the next time you open it.
By design, the file is hidden from Finder (names beginning with a dot are hidden on Unix-based systems). You will only notice it when you look inside a folder from the Terminal, share that folder with someone on Windows or Linux, or accidentally commit it to a Git repository.
There is no built-in macOS setting to stop Finder from creating these files on local disks. You can prevent Finder from creating them on network volumes with a defaults command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
Log out and back in for the change to take effect. This only suppresses creation on SMB and AFP shares — local folders will still get them.
The ds_store File Meaning in Practice: What Is Actually Inside?
A .DS_Store file is a binary property list in a proprietary Apple format. You cannot open it in a text editor meaningfully, but third-party parsers can read it. The contents are almost always completely mundane: icon coordinates, sorting preferences, and the like.
Occasionally the file can reveal which filenames exist in a directory — even filenames of files that have since been deleted. This is why some security-conscious teams include .DS_Store in their .gitignore and block it from being served by web servers. It is not a serious vulnerability in most contexts, but it is a minor information disclosure if your web root accidentally contains one.
.DS_Store in Git: Why It Keeps Showing Up
The most common place developers encounter .DS_Store problems is in Git repositories. If you initialize a Git repo on a Mac and do not have a .gitignore entry for it, Finder will create .DS_Store files and git status will flag them as untracked files. Commit once by accident and the file is in your history forever — visible to every collaborator.
How to Keep .DS_Store Out of Git
The standard fix is a .gitignore entry. You have two options:
- Per-repository .gitignore — add a line to the repo's
.gitignorefile:
.DS_Store
**/.DS_Store
- Global .gitignore — apply the rule to every repo on your Mac without touching each project:
# Create or edit the global ignore file
echo ".DS_Store" >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
If .DS_Store is already tracked in a repository, you need to untrack it first:
git rm --cached .DS_Store
git commit -m "Remove .DS_Store from tracking"
Run that recursively with find . -name .DS_Store -print0 | xargs -0 git rm --cached --ignore-unmatch if the file appears in multiple subdirectories.
Is It Safe to Delete .DS_Store?
Yes — deleting .DS_Store files is completely harmless. The only consequence is that Finder loses its memory of how you had arranged icons or which view mode you preferred in that folder. Finder simply recreates the file with defaults the next time you open the directory.
You will not lose documents, photos, application data, or system settings. .DS_Store is display metadata, not user data.
How to Delete .DS_Store Files from Terminal
To remove every .DS_Store file in your home directory and its subdirectories:
find ~ -name ".DS_Store" -delete
To target a specific project folder:
find /path/to/project -name ".DS_Store" -delete
Note: the find command with -delete is permanent — it does not move files to the Trash. That is fine for .DS_Store, but keep that behavior in mind before adapting the command to other file types.
How Much Space Do .DS_Store Files Use?
Each .DS_Store file is tiny — typically between 6 KB and a few dozen kilobytes. On a Mac with tens of thousands of folders, they can collectively amount to a few megabytes at most. Reclaiming space is not really the motivation for deleting them; keeping Git history clean and not leaking folder structure to web visitors are the more practical reasons.
Dealing with .DS_Store Alongside Other Mac Junk
macOS accumulates a lot of hidden files alongside .DS_Store: application caches in ~/Library/Caches, system logs in /var/log, Xcode derived data, and purgeable storage that macOS holds onto "just in case." If you are doing a broader cleanup, Crumb automatically identifies .DS_Store files as safe junk alongside caches, logs, and other temporary files — and flags anything non-obvious for your review before touching it. That is useful if you want a single pass rather than hunting each file type manually.
Quick Reference: .DS_Store Facts
| Question | Answer |
|---|---|
| What creates it? | macOS Finder, automatically on every directory open |
| What does it store? | Folder view preferences (icon positions, view mode, sort order) |
| Safe to delete? | Yes — Finder recreates it on next open |
| Should it be in Git? | No — add to .gitignore |
| Can you stop Finder creating it? | On network volumes only (defaults write command above) |
| Is it a security risk? | Minor: can expose filenames — keep off public web roots |
Conclusion
.DS_Store is one of the most harmless files on your Mac — Finder's way of remembering how you like your folders to look. The file becomes a nuisance mainly when it slips into Git commits or gets served from a web directory. The fixes are straightforward: a global .gitignore rule handles the version-control problem, a one-line Terminal command clears them from any folder, and a defaults setting prevents new ones on network shares. If you want to sweep .DS_Store files along with the rest of your Mac's accumulated temporary data in one step, download Crumb and let it identify what is safe to remove before anything gets deleted.