git supports global gitignore files
- Published at
- Updated at
- Reading time
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 checked these files into your version control system. 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
git config --global core.excludesfile ~/.gitignore_global
This command creates the following setting in your global
# .gitconfig [core] excludesfile = ~/.gitignore_global
.gitignore_global file, and voila! You'll never have to fear committing
DS_Store files again!
# .gitignore_global .DS_Store
- How to apply directory dependent git configuration using conditional imports
- How to add a directory but ignore included files in git
- A git alias to show a detailed git branch overview
- How to use git's file diff outside of git repositories
- git commit accepts several message flags (-m) to allow multiline commits