I found a handy tool for generating .gitignore files for whatever type of project your working on whether you are building in Unreal or Unity as well as whether you are using Visual Studio or CLion like I am.
Just type in the software you are using and it will automatically add unnecessary files to your .gitignore specific for that software, you can even add multiple software. I use this tool all the time.