Published at
Updated at
Reading time
1min
This post is part of my Today I learned series in which I share all my web development learnings.

Today I found a LinkedIn post from Luciano Mammino, which shared a small but super handy git configuration fact.

Suppose you're on macOS, you know .DS_Store files. The "Desktop Services Stores" hold the folder’s custom attributes, icon positions, and other operating system metadata. These files are useless for web development, though.

And if you're a "YOLO, I commit everything!" person, you probably have accidentally checked these files into your version control system before. But there's help!

As Luciano shared, with a little bit of git configuration, you can eliminate this problem forever. Run the following command to define .gitignore_global as the core.excludesfile option.

git config --global core.excludesfile ~/.gitignore_global

This command creates the following setting in your global .gitconfig.

# .gitconfig
[core]
  excludesfile = ~/.gitignore_global

Create a .gitignore_global file in your user home directory, and voila! You'll never have to fear committing DS_Store files again!

# .gitignore_global
.DS_Store
Was this TIL post helpful?
Yes? Cool! You might want to check out Web Weekly for more quick learnings. The last edition went out 1 days ago.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles