title: explain gitignore pattern matching
body: <p>I have the following directory tree:</p>
  
  <pre><code>&gt; #pwd is the repo   
  &gt; tree -a
  .
  ├── .git
  │   |.....
  ├── .gitignore
  ├── README.md
  ├── f1.html
  ├── f2.html ... and some more html
  ├── images
  │   └── river.jpg
  &gt;
  </code></pre>
  
  <p>I also have the following in my <code>.gitignore</code>:</p>
  
  <pre><code>&gt; cat .gitignore
  *
  !*.html
  !images/*.*
  &gt;
  </code></pre>
  
  <p>I would like all files in the images directory to be included in the repo. But that is not happening. I got it to work using the following in gitignore:</p>
  
  <pre><code>*
  !*.html
  !images*
  !*.jp*g
  </code></pre>
  
  <p>What is happening here? Is there a foolproof way to test gitignore. I checked the <a href="https://git-scm.com/docs/gitignore" rel="noreferrer">documentation</a>. Here is the point it don't understand (this is under <strong>pattern format</strong> heading):</p>
  
  <blockquote>
    <p>Otherwise, Git treats the pattern as a shell glob suitable for
    consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the
    pattern will not match a / in the pathname. For example,
    "Documentation/*.html" matches "Documentation/git.html" but not
    "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html".</p>
  </blockquote>