The solution of Jamie FlournoyThe solution of Jamie Flournoy works great. Here is a bit enhanced version to keep the .htaccess :
# Ignore everything in this directory
*
# Except this file
!.gitignore
!.htaccess
With this solution you are able to commit a empty folder, for example /log, /tmp or /cache and the folder will stay empty.