April 28, 2021

Ignore files globally in Git

When working with Git, you can ignore files and folders by putting those on a .gitignore file on the project’s root. However, if want to ignore files globally, instead of doing so in a per-project basis, you can create a global ignore file.

If you’re on a Mac, run:

# go to home directory
cd ~

# create .gitignore_global file
touch .gitignore_global

# run git command to assign that file as a global ignore
git config --global core.excludesfile ~/.gitignore_global

# go edit your global config
code .gitignore_global # or nano, or other editor yo prefer

Read more & source

https://stackoverflow.com/questions/7335420/global-git-ignore/22885996#22885996