title: ignore certain files in all folders using a single .gitignore file
body: <p>After reading several questions about <code>.gitignore</code> I have found no one that could answer my question:</p>
  
  <p>What do I have to add to .gitignore to ignore all files with a certain ending, say 
  <code>*.txt</code> in all folders.</p>
  
  <p>I'd prefer to only have one <code>.gitignore</code> file at top level.</p>
  
  <p>I tried several things but none worked.</p>
  
  <p>This is what I tested (<code>.gitignore</code> was added to the repository before, no other file was added):</p>
  
  <pre><code>  $ ls
    abc.txt  content
  
    $ ls content/
    abc.txt  def.other  def.txt
  
    $ echo "" &gt; .gitignore
  
  
    $ git status --ignored --untracked-files=all
    # On branch master
    # Changes not staged for commit:
    #   (use "git add &lt;file&gt;..." to update what will be committed)
    #   (use "git checkout -- &lt;file&gt;..." to discard changes in working directory)
    #
    #       modified:   .gitignore
    #
    # Untracked files:
    #   (use "git add &lt;file&gt;..." to include in what will be committed)
    #
    #       abc.txt
    #       content/abc.txt
    #       content/def.other
    #       content/def.txt
    no changes added to commit (use "git add" and/or "git commit -a")
  </code></pre>
  
  <p>This is as expected: all files show up since .gitignore is empty.</p>
  
  <pre><code>  $ echo "*.txt" &gt; .gitignore
  
    $ git status --ignored --untracked-files=all
    # On branch master
    # Changes not staged for commit:
    #   (use "git add &lt;file&gt;..." to update what will be committed)
    #   (use "git checkout -- &lt;file&gt;..." to discard changes in working directory)
    #
    #       modified:   .gitignore
    #
    # Untracked files:
    #   (use "git add &lt;file&gt;..." to include in what will be committed)
    #
    #       content/def.other
    # Ignored files:
    #   (use "git add -f &lt;file&gt;..." to include in what will be committed)
    #
    #       abc.txt
    no changes added to commit (use "git add" and/or "git commit -a")
  </code></pre>
  
  <p>Why don't the files content/abc.txt and content/def.txt show up in the list?</p>
  
  <pre><code>  $ git clean -n
    Would not remove content/
  </code></pre>
  
  <p>I thought they would show up here too.</p>
  
  <pre><code>  $ echo "" &gt; .gitignore
  
    $ git clean -n
    Would remove abc.txt
    Would not remove content/
  
    $ cd content
  
    $ git clean -n -x
    Would remove def.other
  
    $ git clean -n -x
    Would remove abc.txt
    Would remove def.other
    Would remove def.txt
  </code></pre>
  
  <p>If the files content/abc.txt and content/def.txt are shown by <code>clean -n -x</code> but not by <code>clean -n</code>, I think they are ignored. But then why don't they show up in <code>git status --ignored --untracked-files=all</code>?</p>