title: How to ignore everything in a directory except one file
body: <p>Repo structure:</p>
  
  <pre><code>.gitignore
  file1
  file2
  dir/
      file3
      &lt;stuff&gt;
  </code></pre>
  
  <p>I want to ignore everything inside <code>dir</code> except file 3. Here's what I have in my <code>.gitignore</code> file:</p>
  
  <pre><code>dir/*
  !dir/file3
  </code></pre>
  
  <p>But this doesn't seem to work. <code>git</code> still tries to index everything in <code>dir</code>. How do I fix this?</p>
  
  <p><strong>UPDATE</strong> - Fixed after deleting the old .gitignore file, and making a new one. The new one was <em>not</em> made using <code>&gt; .gitignore</code>.</p>