add everything in a directory but a file to .gitignore code example
Example 1: gitignore folder
in .gitignore:
folder/
Example 2: git ignore content of a folder
# exclude everything
somefolder/*
# exception to the rule
!somefolder/.gitkeep
in .gitignore:
folder/
# exclude everything
somefolder/*
# exception to the rule
!somefolder/.gitkeep