I learned this while using IntelliJ, because it suggests both options. I searched for the difference and, once understood, I was able to use the knowledge everywhere.
The other useful advice is when there is a full folder you want to ignore. Putting a .gitignore with a single "*" ignores the full folder...including the gitignore file itself.
I do use it when I quickly need to ignore the .idea folder