Reasons to NOT add ".DS_Store" to the .gitignore file

I’m contributing to an open source Rails app. I submitted a pull request to add .DS_Store to the .gitignore file. The purpose is to prevent people from accidentally adding the .DS_Store to the source code. Some people are objecting to this, saying that it’s easy to use global gitignore.

While this doesn’t directly affect me (since I use Linux instead of MacOS), I’ve made removing .DS_Store and adding .DS_Store to the .gitignore file to be a standard part of joining a Rails app. If you use my Rails Neutrino tool ( or Generic App gem ( to start a new Rails app, you start off with .DS_Store already in the .gitignore file.

Global gitignore on MacOS may be easy to use, but I still don’t understand the objection to adding .DS_Store to .gitignore. Can any of you shed some light on why people might NOT want .DS_Store listed in .gitignore? Is it really that beneficial to keep the .gitignore file as short as possible? It seems to me that it’s better to have .DS_Store in .gitignore than risk facing the annoyance of accidentally committed .DS_Store files later. Can you really count on everyone to have global gitignore set?

I don’t have a super strong opinion on this but I’d personally lean towards not having .DS_Store in a project-specific gitignore. The reason for that is the global gitignore is exactly the right place for this rule as it applies system-wide. On the other hand, project .gitingore files should only list what applies to a given repository.

I’d say the right solution would be a mix of:

  1. Developers learning a bit about the tools they use.

  2. git having more sensible defaults on a per-platform basis.

I don’t see any benefit to not including it.

I can understand the argument for placing it in a global .gitignore, but then again, if including it in a project .gitignore prevents future PR rejections because a .DS_Store is accidentally included (and the follow up discussion on “use global gitignore”), then I would call it a win. I feel PR’s should be centered around talking about the code itself, and often times get caught up in minor details or overly opinionated discussions about nothing of import. I am in the camp of avoiding that whenever possible.

I can also see arguments for not using a global .gitignore - if you have many projects on your system, this could become difficult to maintain.

Then again, .DS_Store will likely never be included in any repository, ever, but it seems a little nit-picky to me to be over-zealous about not including it in a project .gitignore. I don’t think it’s going to hurt anyone. People learn about tools on their own time, and knowing, or not knowing, about a global .gitignore is probably not reflective of the code quality from that contributor as a whole.

Just my .02.