This method is only for macOS, so Windows users should look up the specifics elsewhere.
Git config settings have three levels: system-wide (system), user-wide (global), and repository-specific (local). In this case, we’ll configure the system settings.
On Mac, the gitconfig path
is as follows:
| OS | gitconfig path
|:-----:|:-----:|
| Mac |/usr/local/git/etc/gitconfig|
In this gitconfig file
, write what you always want to ignore:
[core]
excludesfile = /Users/your_user_name/.gitignore_system
Once the setting is properly configured, it will show up in the list:
$ git config --system --list
core.excludesfile=/Users/Username/.config/git/.gitignore_system
If there’s no git folder
in the hidden .config
folder in your home directory, create one, and then create a .gitignore_system
file inside it. In this file, write what you always want to ignore.
In my case, I only include basics like macOS
, IntelliJEDEA
, and VisualStudioCode
.
When changing Git settings, sometimes the cache may retain old settings, so it’s a good idea to clear the cache.
Remove unnecessary files:
$ git rm -rf --cached .
$ git add .