DEV Community

Lukas Heller
Lukas Heller

Posted on

6 2

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.

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay