title: GIT: how to list all gitignore rules in a folder
body: <p>What I want to do is to list all <code>gitignore</code> rules inside a folder. Assume the following folder structure:</p>
  
  <pre><code>project/
  project/folderA/
  </code></pre>
  
  <p>Now if I want some <code>gitignore</code> rules for my whole project, I'd put it in <code>project/.gitignore</code>, but I could also add some rules to <code>project/folderA/.gitignore</code>, which as I understand, would apply to <code>project/folderA</code> and its subfolders only.</p>
  
  <p>Now assume I do have some rules in both <code>.gitignore</code> files, and I'm in <code>project/folderA</code>, how can I list all <code>gitignore</code> rules that apply here? I need to see all the union of the ones inherited from parent folders and the ones existing in the current folder.</p>
  
  <p>You can use the following command:</p>
  
  <pre><code>git check-ignore *
  </code></pre>
  
  <p>which would list you everything directly under the current folder which is ignored, and if you add a <code>-v</code> option, it would also show you the rule which has caused it to be ignored.</p>
  
  <p>What I need is not to give an example and see if it's ignored or not, I simply need to see all the rules applying to the current folder.</p>
  
  <p><strong>EDIT</strong>: Some suggest that the <code>.gitignore</code> file in the subfolder overrides the parent and only that file needs to be checked. I've tested with git version <code>2.13.3</code> and this is not how it works. If I have <code>patternA</code> in parent folder, it IS ignored in the subfolder even if I don't have that same pattern in the subfolder's <code>.gitignore</code> file.</p>
  
  <p><strong>EDIT 2</strong>: Consider the following working example:</p>
  
  <pre><code>[user@machine tmp]$ mkdir test
  [user@machine tmp]$ cd test/
  [user@machine test]$ git init
  Initialized empty Git repository in /tmp/test/.git/
  [user@machine test]$ echo "a"&gt;.gitignore
  [user@machine test]$ mkdir p
  [user@machine test]$ cd p
  [user@machine p]$ echo "b"&gt;.gitignore
  [user@machine p]$ echo "c"&gt;.gitignore
  [user@machine p]$ touch a 
  [user@machine p]$ touch b
  [user@machine p]$ cd ..
  [user@machine test]$ touch a
  [user@machine test]$ touch b
  [user@machine test]$ git add .
  [user@machine test]$ git status
  On branch master
  
  Initial commit
  
  Changes to be committed:
    (use "git rm --cached &lt;file&gt;..." to unstage)
  
      new file:   .gitignore
      new file:   b
      new file:   p/.gitignore
  
  [user@machine test]$ cd p
  [user@machine p]$ git list-git-ignore-rules-applied-here &lt;-- hypothetical
  </code></pre>
  
  <p>As you can see, the only rule in the parent folder is <code>a</code>, and the two rules in the <code>p</code> folder are <code>a</code> and <code>b</code>, hence niether of those created files being tracked after <code>git add .</code>. Now the last line of that example code is what I need, which should give me the output:</p>
  
  <pre><code>a
  b
  c
  </code></pre>