Handling Mac OSX DS_Store In Your Projects
If you use a Mac you must have seen the pesky DS_Store files at a lot of places. These files store custom attributes of a folder on your Apple macOS. These files, though important on your local machine, may get into your projects sometimes and get committed in Git repositories as well. If you publish your open source codes on marketplaces like ThemeForest then they require that you make sure that there are no such files in the codes submitted.
There are 2 ways in which we have the DS_Store files in our projects.
Delete DS_Store Files Recursively
In this step, we delete all DS_Store files recursively from a directory. To do this go to the folder where you want to delete all these files from your terminal and enter the following command
$ find . -name '.DS_Store' -type f -delete Please make sure you are in the correct folder and you know what you are doing. We will not be responsible for any unwanted effects that may happen on your computer
Globally Ignore DS_Store from Git Commits
This is probably the safest way to make sure that DS_Store does not enter in your Git repositories. To do this we will create a global Git ignore file
$ echo .DS_Store > ~/.gitignore_global
Now we will configure Git to use this global ignore file so that it takes effect to all your Git repo
$ git config --global core.excludesfile ~/.gitignore_global
That’s it. Now your DS_Store files will not get into your repo’s and you can code with peace!
Level: Intermediate
Technologies: Linux / Unix, Git