title: Git Ignore everything in a directory except subfolders
body: <p>This is my folder structure:</p>
  
  <pre><code>data/
      .gitignore
      uploads/
          .gitignore
  </code></pre>
  
  <p>I would like to commit the folders but not the files inside them.</p>
  
  <p>So I add a .gitignore files in every folder with the following content:</p>
  
  <pre><code># Ignore everything in this directory
  *
  # Except this file
  !.gitignore
  </code></pre>
  
  <p>The problem is that <code>*</code> matches also on directories so git tracks only <code>data/.gitignore</code></p>