github/gitignore · Global/macOS.gitignore

macOS .gitignore Template Explained

Why macOS.gitignore ignores .DS_Store, ._ resource forks, Icon files, and Spotlight, Time Machine and Trash folders, and how to put it in a global gitignore.

Open in generator Open with VisualStudioCode, JetBrains, Xcode, Node

macOS.gitignore blocks metadata files that Finder and the macOS file system create without the user noticing. They have nothing to do with project contents, so this template is recommended for your personal global gitignore (core.excludesFile) rather than the repository.

In practice, not every teammate sets up a global config, so accidentally committed .DS_Store files are common. That is why many teams also put it in the project .gitignore.

Rules explained

PatternWhat it ignores and why
.DS_Store.localizedFinder metadata.DS_Store is the view settings file (icon positions, sorting) Finder creates in each folder. It appears just by opening a folder and contains a list of file names, which can unintentionally reveal information.
._*.AppleDouble.LSOverrideResource forks (AppleDouble)Companion ._filename files created to hold extended attributes when files are copied to non-HFS+/APFS volumes (FAT, network shares).
.VolumeIcon.icnsCustom iconsThe volume icon file. A folder's custom icon is stored as an Icon file whose name ends with a carriage return (CR), which the template catches with a bracket pattern of the form Icon[\r].
.Spotlight-V100.fseventsd.Trashes.TemporaryItems.DocumentRevisions-V100System indexes and TrashThe Spotlight index, file system event log, Trash and document version store created at the root of external disks or volumes.
.com.apple.timemachine.donotpresent.com.apple.timemachine.supportedBackups.backupdb.MobileBackupsTime MachineMarker files and backup folders created on Time Machine backup disks.
.AppleDB.AppleDesktopNetwork Trash FolderTemporary Items.apdiskAFP shared foldersDatabases and folders that AFP (Apple Filing Protocol) file servers create on shared volumes. Even though the names contain spaces, the gitignore patterns can be written as-is.
__MACOSX/Unzip by-productsThe resource fork folder that appears when a zip created on macOS is extracted with another tool.

Practical notes

Original template

macOS.gitignore44 rules
# General.DS_Store.localized__MACOSX/.AppleDouble.LSOverrideIcon[
]# Resource forks._*# Files and directories that might appear in the root of a volume.DocumentRevisions-V100.fseventsd.Spotlight-V100.TemporaryItems.Trashes.VolumeIcon.icns.com.apple.timemachine.donotpresent.com.apple.timemachine.supported.PKInstallSandboxManager.PKInstallSandboxManager-SystemSoftware.hotfiles.btree.vol.file.disk_label*lost+found.HFS+ Private Directory Data[
]# Directories potentially created on remote AFP share.AppleDB.AppleDesktopNetwork Trash FolderTemporary Items.apdisk# Mac OS 6 to 9Desktop DBDesktop DFTheFindByContentFolderTheVolumeSettingsFolder.FBCIndex.FBCSemaphoreFile.FBCLockFolder# Quota system.quota.group.quota.user.quota.ops.group.quota.ops.user# TimeMachineBackups.backupdb.MobileBackups.MobileBackups.trashMobileBackups.trashtmbootpicker.efi

Templates from github/gitignore/Global/macOS.gitignore @356fd7b (2026-09-11) · CC0-1.0

Often used together

More template explanations