title: How to I add something to the .gitignore so that the match is not recursive?
body: <p>How to I add something to the <code>.gitignore</code> so that the match is not recursive?</p>
  
  <p>For example, I wish to ignore the directory <code>foo</code> and the file <code>bar.txt</code> in the current directory, but not any that exist in subdirectories.</p>
  
  <p>I have tried this for my <code>.gitignore</code> file:</p>
  
  <pre><code>foo/
  bar.txt
  </code></pre>
  
  <p>But unfortunately git applies this recursively, so that <code>otherdir/bar.txt</code> and <code>otherdir/foo/</code> also get ignored, which is not what I want.</p>
  
  <p>(Is there a command in git that shows me all ignored files, and reference the <code>.gitignore</code> file that is responsible for the file being ignored?  This would be useful for debugging.)</p>