Fundamentals 3 min read

How to Globally Ignore macOS .DS_Store Files in Git

This guide explains why macOS .DS_Store files appear in Git repositories, how to add them to a project .gitignore, and provides a step‑by‑step method to set up a global .gitignore so the files are ignored across all your repositories.

Programmer DD
Programmer DD
Programmer DD
How to Globally Ignore macOS .DS_Store Files in Git

.DS_Store files are hidden macOS metadata files that can accidentally be added to a Git repository, which is annoying for developers.

Normally you add .DS_Store to a project‑level .gitignore, but you can also set a global ignore file so the rule applies to all repositories on your machine.

Step 1: Create a global ignore file, e.g. ~/.gitignore, and add the patterns you want to exclude, for example:

.DS_Store

You can add other patterns as needed.

Step 2: Tell Git to use this file globally:

git config --global core.excludesfile ~/.gitignore

After this configuration, Git will automatically ignore the listed files in every repository. Remember that for team projects you should still keep a repository‑specific .gitignore to share ignore rules with collaborators.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

GitmacOSVersion Control.DS_Storeglobal .gitignore
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.