Putting .DS_Store or editor swap files into the .gitignore of every project is silly, since they come from my machine and not from the project. A global ignore file keeps them out of all repositories in one go.
git config --global core.excludesFile ~/.gitignore_global
printf '.DS_Store\n*.swp\n.idea/\n' >> ~/.gitignore_global
The file uses the same patterns as a normal .gitignore. Git reads it for every repository you use, next to the project’s own ignore rules.
You may not even need the setting. The manual says the default is $XDG_CONFIG_HOME/git/ignore, or $HOME/.config/git/ignore when that variable is not set, so a file at ~/.config/git/ignore is picked up automatically.
When a file is ignored and you wonder why, git check-ignore -v <file> prints the rule and the file it comes from.
Caveats: this is personal, so a rule your teammates need still belongs in the project’s .gitignore. A file that git already tracks stays tracked, because ignore rules only apply to untracked files. And a path in the config is not expanded in every case, so if the file is not picked up, check with git config --get core.excludesFile that the value is what you expect.
Further reading: git config, core.excludesFile (Git documentation)
Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more