A global .gitignore

A small tip that I’ve come across recently: It is possible to have a global .gitignore file that applies to every Git repository on your machine.

Start by making a .gitignore file in your home directory, with the files you want to ignore, and place in your home directory:

# ~/.gitignore

.vimrc.local
*.swp

.idea
.DS_Store

Then, tell Git to use this file as global .gitignore by running in your shell:

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

You can also take inspiration from my own global .gitignore file. Enjoy!