title: What is the difference between a single /* and double /** trailing asterisk in a .gitignore file?
body: <p>Consider the following two patterns in a <code>.gitignore</code> file</p>
  <pre><code>foo/*
  foo/**
  </code></pre>
  <p>The <a href="https://git-scm.com/docs/gitignore#_pattern_format" rel="nofollow noreferrer">pattern format specification</a> states:</p>
  <blockquote>
  <p>An asterisk <code>*</code> matches anything except a slash. [...]</p>
  </blockquote>
  <blockquote>
  <p>A trailing <code>/**</code> matches everything inside. For example, <code>abc/**</code> matches all files inside directory <code>abc</code>, relative to the location of the .gitignore file, with infinite depth.</p>
  </blockquote>
  <p>That sounds like the same thing to me when used at the end of a pattern directly after a slash. I did test a few cases - with, and without subdirectories below <code>foo</code> and various negated patterns - and did not observe any difference.</p>
  <p><strong>Is there any scenario when one would chose <code>/**</code> over <code>/*</code>?</strong></p>
  <hr />
  <p>At first, I expected to see a use case with a pattern like the one below, but there wasn't because both patterns will ignore everything inside and as the specification also denotes <em>&quot;[...] it is not possible to re-include a file if a parent directory of that file is excluded [...]&quot;</em></p>
  <pre><code>foo/*
  !foo/a/b/c/file.txt
  
  foo/**
  !foo/a/b/c/file.txt
  </code></pre>