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.
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
| Pattern | What it ignores and why |
|---|---|
.DS_Store.localized | Finder 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.LSOverride | Resource forks (AppleDouble)Companion ._filename files created to hold extended attributes when files are copied to non-HFS+/APFS volumes (FAT, network shares). |
.VolumeIcon.icns | Custom 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-V100 | System 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.MobileBackups | Time MachineMarker files and backup folders created on Time Machine backup disks. |
.AppleDB.AppleDesktopNetwork Trash FolderTemporary Items.apdisk | AFP 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
- Global setup: run
git config --global core.excludesFile ~/.gitignore_globaland put this template in that file. If you do not set it, git uses the default path~/.config/git/ignore. - Remove already committed
.DS_Storefiles withgit rm --cached. The “Every tracked file matched by .gitignore” mode in the Untrack tab handles them all at once. - The
._*rule does not block every file starting with an underscore. It applies only to names starting with._(dot plus underscore).
Original template
macOS.gitignore
# 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