How do you get git to ignore all contents of a directory?

Add a sessions/.gitignore file with

*
!.gitignore

The second line tells git not to ignore the .gitignore file, so the folder is not empty but everything else is ignored.


If I'm remembering correctly, you can do this by creating a .gitignore file in the sessions folder with [^.]* as its contents.