DEV Community

Please remove that .DS_Store

spO0q on January 02, 2022

macOS automatically creates .DS_Store when you open a folder with Finder, the default file manager. The operating system stores some information in...
Collapse
 
andreidascalu profile image
Andrei Dascalu

I am partially against globally ignoring .DS_Store in your local machine, if you work collaboratively with others. Why?
Because if you ignore DS_Store files in your local globally but others don't, they might still push theirs.
On the other hand, since you ignore those files locally, you will have no idea because changes to them or their presence will be ignored.
You can't enforce ignoring DS_Store in local environments (in a way you can check), but you can make it a thing you look for in every project gitignore.

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
andreidascalu profile image
Andrei Dascalu

It's not about replacing. It's about the risk that if you do ignore it locally in a global way, you will not be in a position to notice it clearly if the project doesn't. Which in itself is a risk.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
andreidascalu profile image
Andrei Dascalu

Global configuration only applies to you, not the team. The risk is that it makes you unaware of what the team does because it applies globally but only locally to you, so the result is that you are left unaware that others in the project are free to message with DS_Store.
In a nutshell, it prevents YOU from doing something stupid but it also prevents you from seeing the sign that a project allows others to do something stupid.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
leob profile image
leob

I think he does have a bit of a point here, so there are pros and cons to doing this, but that doesn't take away from the usefulness of your tip - not to mention raising awareness of the risk of accidentally deploying .DS_Store files on a server - thanks!

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
nitpum profile image
nitpum • Edited

Sorry for my English. I have a example about what @andreidascalu talking about.

My colleague left the company so maintaining his project now become mine. Whatever reason he doesn't ignore .DS_Store in the project's .gitignore. But, I have it ignored globally so I don't know it's not ignored in the project. A week later, a new intern join this project. he doesn't have global ignore like me so he accidentally commit and push .DS_Store to remote

In this example, it's just a .DS_Store what about .env or something that is really important like a key or token. I should notice and fix project's .gitignore on the first day if I don't have globally ignore.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
nitpum profile image
nitpum

I think it should be secure both way

  1. notice the git incident and prevent it in the first place
  2. secure the server

securing the server is only prevents it through to the server but the incident has already happened. the git incident is shouldn't happen in the
first place.

for pull request, we don't notice it until pull request is created. if we don't ignore it globally, it will be noticed faster. also have to clean up the commit, if sensitive files like .env already push to remote for creating pull request.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
nitpum profile image
nitpum • Edited

The git incident problem will not happen in 2 case

  • the project's .gitignore has been set correctly
  • everyone set their global gitignore correctly

For me set global gitignore is not scalable. When many people join the project later you need to tell them how to set their global gitignore properly or have some documentation for them. what if they miss config it, even they config it correctly it does not guarantee they will not miss config it later. It is hard to know when and what they miss config in later.

the project's .gitignore is more scalable when more people join the project later you don't need to have some documentation(it's still good to have one) or tell everyone that they need to set global gitignore.

I don't use global gitignore when I join a new project I can notice that the project's .gitignore is missing some config. This make me notice it fast and fixed the config to be correct for the other people. people who join the project later don't even need to set their global gitignore.

If everyone doesn't use global config when the project's .gitignore has something wrong everyone will notice it fast and fix it in no time.
If everyone uses global config it's hard to notice when .gitignore has missed config.

The project's .gitignore is prevent everyone to make a mistake.
The global gitignore is only prevent you to make a mistake but not the other and it makes you hard to know when the project's .gitignore is invalid.

Thread Thread
 
yawaramin profile image
Yawar Amin

Ignoring .DS_Store globally on my dev machine is a basic convenience measure. If this is a real worry in the team regarding security, then the team should be using a CI pipeline and running this (and other) security checks during pipeline builds. For example, check that .DS_Store must be mentioned in every project's .gitignore file, fail the build otherwise.

Thread Thread
 
leob profile image
leob

Yeah it sounded like a good idea but I've come to realize that what I don't like about it is its "do it once and then forget about it" nature. It's a bit, out of sight, out of mind, which mean that at some point you wouldn't even be aware anymore that you have it. The issue would be "solved" but you'd lose sight of it and not be aware of it.

Collapse
 
sherrydays profile image
Sherry Day

I suspect many see .DS_Store and have absolutely no idea what it is. Thanks for writing this!

Collapse
 
nickfrosty profile image
Nick Frostbutter

I think it should for sure be removed from git repos. Especially as a Windows user. It is super annoying! Everyone should add it to their .gitignore. No doubt!

Collapse
 
saviorys profile image
saviorys

thanks for writing this, I never knew I could remove them LOL