Git doesn’t permit acknowledging an empty folder so a folder must be kept with something in it, even how trivial a file may seem.
First, create an empty folder:
touch somefolder/.gitkeep
For instance, you can place an empty file of .gitkeep type in the directory that you want to keep. Afterwards, in your .gitignore file, use this:
Ignoring the full contents in the folder
somefolder/*
Permit use of only the .gitkeep file
!somefolder/.gitkeep
After committing both .gitignore and .gitkeep files, the folder will be included in your repository.