I've done this a few times on a live stream and there is always someone unaware of this so I wanted to share.
Assuming you have Node.js installed on your machine, you can run
npx gitignore your_language, e.g.
npx gitignore node, and it will generate a gitignore file for you for the given language.
Here's a clip from my stream today showing it in action. Maybe you'll find it useful in your next project!
Photo by Gabriel Heinzer on Unsplash