Stop Committing `.DS_Store` Files to Git
If you've ever worked with Git on macOS, chances are you’ve seen the mysterious .DS_Store file show up in your repositories. What is .DS_Store? .DS_Store is a hidden file that macOS creates in every folder to store attributes like icon positions, window size and other visual information. It is one of those things that seems to sneak in when you’re not looking. Why You Should Ignore It There’s absolutely no reason to track .DS_Store in Git. It creates unnecessary merge conflicts, and adds noise to pull requests. Plus, it’s platform specific and your teammates on Linux or Windows won’t care about how you like your icons arranged. How to Ignore It The fix is simple. Add this lines to your project's .gitignore file: .DS_Store If you want to make sure it never ends up in any repo on your system again, you can add it globally: git config --global core.excludesfile ~/.gitignore_global Then, in your ~/.gitignore_global file, add: .DS_Store Cleaning Up If it's already staged you can unstage and remove the path from index as follows: git rm --cached '*.DS_Store' That’s it. You’ve now taught Git to look the other way when it sees .DS_Store.

If you've ever worked with Git on macOS, chances are you’ve seen the mysterious .DS_Store
file show up in your repositories.
What is .DS_Store
?
.DS_Store
is a hidden file that macOS creates in every folder to store attributes like icon positions, window size and other visual information. It is one of those things that seems to sneak in when you’re not looking.
Why You Should Ignore It
There’s absolutely no reason to track .DS_Store
in Git. It creates unnecessary merge conflicts, and adds noise to pull requests. Plus, it’s platform specific and your teammates on Linux or Windows won’t care about how you like your icons arranged.
How to Ignore It
The fix is simple. Add this lines to your project's .gitignore
file:
.DS_Store
If you want to make sure it never ends up in any repo on your system again, you can add it globally:
git config --global core.excludesfile ~/.gitignore_global
Then, in your ~/.gitignore_global
file, add:
.DS_Store
Cleaning Up
If it's already staged you can unstage and remove the path from index as follows:
git rm --cached '*.DS_Store'
That’s it. You’ve now taught Git to look the other way when it sees .DS_Store
.