This short articles shows how to setup a global .gitignore file, to exclude files or directories for all your git repositories.
This is very useful for editor files or .env file, and prevents accidental commits. I also added common directories for Java and NodeJS related developments (target/ and node_modules), and IntelliJ IDEA files (*.iml and .idea/)
Thus said, you should also always setup a .gitignore file in your projets, as the global file only work for you, and will not be shared with the code of your project.