Git β€’ Operating Systems

macOS System Files (.DS_Store) .gitignore Template

macOS Finder creates invisible `.DS_Store` metadata files in almost every folder you open. Committing these pollutes repositories and generates useless merge conflicts across teams.

.gitignore(19 lines)
1# General macOS files
2.DS_Store
3.AppleDouble
4.LSOverride
5
6# Icon metadata
7Icon
8
9# Thumbnails and Spotlight
10._*
11.Spotlight-V100
12.Trashes
13
14# Files that might appear in the root of a volume
15.DocumentRevisions-V100
16.fseventsd
17.TemporaryItems
18.VolumeIcon.icns
19.com.apple.timemachine.donotpresent

Key Rules & Why They Are Ignored

.DS_Store

Desktop Services Store file containing Finder view settings, icon positions, and window dimensions.

._*

AppleDouble companion file created on non-HFS/APFS filesystems (USB drives, network shares).

Already Committed Ignored Files? Purge from Git Cache

Adding a pattern to .gitignore does NOT delete files that were already tracked in previous commits. Run this command to remove them from tracking without deleting your local copies:

git rm -r --cached . && git add . && git commit -m "Untrack ignored files"

Frequently Asked Questions About macOS System .gitignore

Frequently Asked Questions

Frequently Asked Questions

Everything you need to know regarding specifications, syntax, and security best practices.

It is best practice to add `.DS_Store` to your global gitignore (`git config --global core.excludesfile ~/.gitignore_global`), but adding it to project gitignores protects Windows and Linux teammates.