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.
.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_StoreYou can add other patterns as needed.
Step 2: Tell Git to use this file globally:
git config --global core.excludesfile ~/.gitignoreAfter 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
