DEV Community

Lukas Heller
Lukas Heller

Posted on

Quickly ignore .DS_Store files globally

A global .gitignore file is a very useful thing - if you use one. Personally i didn't, until recently. But there is one special file that allways bothered me in my workflow: .DS_Store
For this post, it doesn't matter what these files are or why they exist. What matters is that these small files are annoying because they are often created and committed without notice.

So here's a quick one-line command solution for anyone, who doesn't use a global .gitignore yet.*

TL:DR

git config --global core.excludesfile "~/.gitignore" &&  echo .DS_Store >> ~/.gitignore
Enter fullscreen mode Exit fullscreen mode

Explanation

This command

  • configures the path to a global exclude file (we'll just call it .gitignore, but it could also be .global_gitignore or somehting else) to the home directory (~/), where your global .gitconfig usually resides too.
  • then this new .gitignore file is created in your home folder (if it doesn't already exists) and a new line with .DS_Store is appended.

*If you are already using a global .gitignore, i'll assume that you are already ignoring these type of files globally. If not - please do so, as it should not be necessary to ignore these an a per project basis.

Heres a quick gist if you want to bookmark this command.

Top comments (0)