.gitignore exclusion is not working for a single file
<pre><code>$ git --version
git version 2.6.4
</code></pre>

<p>I realize this is a duplicate but the other question's answers have not helped. </p>

<p>Folder structure </p>

<pre><code>/
-- dist/
---- samples/ 
---- README.md
---- foo/
---- bar/
---- baz.js 
</code></pre>

<p>I want to ignore everything in dist except samples and README.md. My first few tries at it didn't work, so I settled on just unignoring the README: </p>

<pre><code>dist
!dist/samples/README.md 
</code></pre>

<p>README is a brand new file. The dist folder is not in source control at all. But when I check ignore, it's still being ignored: </p>

<pre><code>$ git check-ignore dist/samples/README.md 
dist/samples/README.md
$ git check-ignore src
   # empty line    
</code></pre>

<p>I've tried: </p>

<ol>
<li>changing the order of the ignores</li>
<li>removing the slash from the beginning of the line</li>
<li>adding a ** in the middle: <code>dist/**/README.md</code></li>
<li>adding a <code>/*</code> to the end of <code>dist</code> on the first line</li>
</ol>

<p>The only other things being ignored are *.js, *.js.map, temp and node_modules. The funny thing is that Webstorm thinks that the file is not being ignored (it changes color) but the command line tool <em>does</em> think it is being ignored. </p>

<p>I don't see what I'm doing wrong. The pattern seems very simple:</p>

<ol>
<li>ignore all the things in this directory </li>
<li>don't ignore this one thing here </li>
</ol>

<p>But it's clearly not working. </p>