title: Whitelist directories with .gitignore
body: <p>I want to have two directories in one git repository.
  My method of choice is to create a git repository in a top-level directory and then use .gitignore to whitelist the two directories of interest.
  Requirements are within the comments of my attempted .gitignore file:</p>
  
  <pre><code># Blacklist everything
  *
  # Whitelist directories of interest and their contents
  # stage files in directory A/ recursively
  !A/
  !A/*
  # stage files in directory B/B1/ recursively (without staging files in B/)
  !B/B1/
  !B/B1/**
  # Whitelist files of interest
  # stage only the .md files (not .txt files)
  !*.md
  </code></pre>
  
  <p>How to write a .gitignore file that whitelists two directories?</p>
  
  <p>The above gitignore file is based on <a href="https://stackoverflow.com/questions/25003448/gitignore-ignoring-whitelisted-folder">.gitignore ignoring whitelisted folder</a></p>
  
  <p>Here is the directory I tested .gitignore on:</p>
  
  <pre><code>$ find A B C
  A
  A/a.md
  A/a.txt
  A/A1
  A/A1/a1.md
  A/A1/a1.txt
  B
  B/b.md
  B/b.txt
  B/B1
  B/B1/b1.md
  B/B1/b1.txt
  C
  C/c.md
  </code></pre>
  
  <p>Here is how I tested the .gitignore file:</p>
  
  <pre><code>$ find A B C            #list all paths
  $ git init
                          #test .gitignore:
  $ git add . --dry-run   #show what would be staged
                          #edit gitignore and test again
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>$ git add . --dry-run
  add 'A/A1/a1.md
  add 'A/a.md
  add 'B/B1/b1.md
  </code></pre>