That's good and all, but as @matthias
mentioned, it's still important to add them to your repositories because other people will also work on them. They might not have configured their global .gitignore like you have, which might cause them to accidentally commit the .env file.
It‘s a good idea to put such things into your global .gitignore.
But keep in mind that you mostly work in projects with other people, so you have to put those things into your repositories .gitignore too, to avoid that your co-workers commit secrets.
oh thank you. :) I care this.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.