Git global recursive directory ignore

Certain IDEs like PyCharm create per-project cache directories with metadata relevant to the IDE configuration for that project. For example, PyCharm creates .idea/ directory for each project. You could edit the .gitignore file for each repository. However, I prefer to ignore files in Git system-wide for all repos as follows:

Tell Git where the global ~/.gitignore file is:

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

Create / edit the ~/.gitignore file to include things like:

.vs/
.mypy_cache/
.idea/
.DS_Store
pip-wheel-metadata/

*.pyc