git config --global core.excludesfile ~/.gitignore_global
touch ~/.gitignore_global

Ignored in every repository on the machine: things about your environment, not the project:

.DS_Store          # macOS
Thumbs.db          # Windows
.vscode/           # VS Code
.idea/             # JetBrains
*.log
.env

A global ignore is personal, machine-wide, shared with no one. A repository’s .gitignore is committed and shared, describing what the project never wants tracked. Editor and OS junk goes global; project tooling’s output goes in the repo.