The .DS_Store file is a hidden system file that macOS creates automatically in every folder you open, storing display settings and folder appearance data for that location.

When you open a folder on a Mac, the operating system remembers how you arranged the files — whether icons were sorted by name or date, how large the preview pane was, where you scrolled to. That information gets saved in a file called .DS_Store (Desktop Services Store) so the folder looks the same way the next time you open it. The file is invisible by default, which is why most Mac users never notice it exists.

The file itself is not a security risk or a sign something is wrong. It is simply macOS doing housekeeping. However, it can cause friction when you move folders between Macs, share them over a network, or sync them to version control systems like Git — because the file changes every time you adjust a window and gets flagged as a modification even though the actual content of your files has not changed.

Key Takeaways

  • .DS_Store files are created automatically by macOS in every folder and contain only display preferences, not personal data or system settings.
  • The file is hidden by default on your Mac but becomes visible when you connect external drives or share folders with Windows users.
  • If you use Git or cloud storage, .DS_Store files can clutter your version history because they change whenever you rearrange a folder view.
  • You can safely delete .DS_Store files without affecting your data, and they will be recreated automatically the next time you open the folder.
  • To prevent .DS_Store files from syncing to shared folders or repositories, you can configure your system or add them to a .gitignore file.

What information .DS_Store actually stores

The .DS_Store file records only visual preferences for a specific folder: the size and position of the window, whether you are viewing files as icons or a list, the sort order, the zoom level, and the position of the sidebar. It does not store file contents, passwords, browsing history, or any personal information beyond how you arranged things in that one folder.

Each folder gets its own .DS_Store file. Your Desktop folder has one, your Downloads folder has another, and so on. If you have never opened a folder, no .DS_Store file exists for it yet. The moment you open it and macOS saves your view preferences, the file appears.

Why .DS_Store files become visible and cause problems

On your own Mac, .DS_Store files stay hidden because macOS is configured to hide files that start with a dot. But the moment you connect an external drive formatted for Mac, or share a folder over a network with Windows users, those files become visible to other systems — and Windows does not hide dot files by default. You will see them cluttering your folder listings.

The bigger problem occurs in shared development environments. If you use Git to version control a project, every time you open a folder and adjust the window size, macOS creates or modifies the .DS_Store file. Git sees this as a change and flags it, even though you have not touched any actual code. This pollutes your commit history with meaningless modifications and creates merge conflicts when multiple people work on the same project.

Cloud storage services like Dropbox, iCloud Drive, and Google Drive also sync .DS_Store files, which means they take up storage space and create unnecessary sync activity. If you are sharing a folder with Windows users through cloud storage, they will see these files and may be confused by them.

How to delete .DS_Store files safely

You can delete any .DS_Store file without harming your system or data. The file will be recreated automatically the next time you open that folder. If you want to remove them from a specific location, open Terminal and run this command:

find /path/to/folder -name ".DS_Store" -delete

Replace /path/to/folder with the actual path to the folder you want to clean. For example, to remove all .DS_Store files from your Desktop, you would use find ~/Desktop -name ".DS_Store" -delete. To remove them from your entire home directory (which takes longer), use find ~ -name ".DS_Store" -delete.

If you are not comfortable with Terminal, you can also use a third-party tool like CleanMyMac or Gemini Photos, which have graphical interfaces for finding and removing these files. However, Terminal is faster and more reliable if you are willing to type the command.

Preventing .DS_Store files from syncing to Git repositories

If you manage a Git project on a Mac, the standard solution is to add .DS_Store to your .gitignore file. This tells Git to ignore the file and never track it, even if it exists in your folder.

Open the .gitignore file in your project root (or create one if it does not exist) and add this line:

.DS_Store

If .DS_Store files are already in your repository, you need to remove them first with git rm --cached .DS_Store, then commit the change. After that, Git will ignore any .DS_Store files you create going forward.

Many open-source projects include .DS_Store in their .gitignore by default for exactly this reason. If you are starting a new project, adding it from the beginning prevents the problem entirely.

Preventing .DS_Store files in shared folders and cloud storage

If you share folders with Windows users or want to keep cloud storage clean, you can prevent macOS from creating .DS_Store files on external drives and network locations. Open Terminal and run:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

This tells macOS to skip creating .DS_Store files on network drives and external volumes, while still creating them on your internal drive (where they do not cause problems). You will need to restart for the change to take effect.

If you want to disable .DS_Store creation everywhere, including your internal drive, run:

defaults write com.apple.desktopservices DSDontWriteStores -bool true

Be aware that disabling .DS_Store entirely means macOS will not remember your folder view preferences, so every time you open a folder it will look the same as the default view. Most people prefer to keep the setting enabled on their internal drive and only disable it for external drives.

What to do if you see .DS_Store on a Windows computer

If you received a folder from a Mac user or connected a Mac-formatted drive to a Windows machine, you may see .DS_Store files in your listings. They are harmless — you can delete them without any consequence. They will not come back unless the folder is opened on a Mac again.

If you are receiving folders regularly from Mac users and want to prevent this, ask them to add .DS_Store to their .gitignore (if using Git) or to run the Terminal command above to disable creation on external drives. Alternatively, you can configure Windows to hide dot files, though this is less common.

Frequently Asked Questions

Is .DS_Store a virus or security threat?

No. .DS_Store is a legitimate system file created by macOS. It contains only folder view preferences and poses no security risk. However, in rare cases, malware has been disguised with a similar name, so if you see a .DS_Store file in an unexpected location or it is behaving strangely, that would be unusual — but the standard .DS_Store file itself is safe.

Will deleting .DS_Store files break my Mac?

No. Deleting .DS_Store files will not harm your system or any of your actual data. The only effect is that the next time you open that folder, macOS will create a new .DS_Store file with default view settings. Your files remain completely intact.

Why does my Mac create .DS_Store files on external drives?

macOS creates .DS_Store files on any drive you open folders on, including external drives and network locations. This is why they show up when you connect a Mac-formatted drive to a Windows computer. You can prevent this by running the Terminal command to disable .DS_Store creation on external drives.

Can I hide .DS_Store files on my Mac?

They are already hidden by default. If you want to see all hidden files on your Mac, press Command+Shift+Period in Finder, and all dot files (including .DS_Store) will become visible. Press the same keys again to hide them.

Do I need to back up .DS_Store files?

No. There is no reason to back up .DS_Store files. They contain only display preferences and are recreated automatically. If you lose them, the only consequence is that your folder views will reset to defaults the next time you open them.