title: Remove all except certain folders from git history
body: <p>I have a complex git repo from which I would like to delete <strong>ALL</strong> files and history except for two folders, let's say:</p>
  
  <pre><code>foo/a
  bar/x/y
  </code></pre>
  
  <p>While <code>git filter-branch --subdirectory-filter</code> would let me select one folder, and make that the new root, it doesn't seem to give me any option for selecting two directories, and preserving their placement.</p>
  
  <p><code>git filter-branch --tree-filter</code> or <code>--index-filter</code> seem like it will let me iterate through every commit in history, where I can use <code>git rm</code> on an unwanted folder. </p>
  
  <p>I cannot seem to find any working way to get these commands to just preserve the two folders I desire while clearing <strong>everything</strong> else.</p>
  
  <p>Thanks!</p>