title: Git filter-branch with index-filter does not work and remove directories as expected
body: <p>Structure of Git repo foo in master branch  </p>
  
  <pre><code>foo/refs/a.txt  
  foo/bar/refs/b.txt  
  </code></pre>
  
  <p>In other branches <code>refs/</code> might be in lots of other places</p>
  
  <h3>Goal</h3>
  
  <p>To remove all instances of the directory refs (and their content) from Git (history)
  Environment: Windows 7 using Git Bash</p>
  
  <h3>Removing refs (Git not involved, tried this just to see that it works by itself)</h3>
  
  <pre><code>find . -name refs -depth -exec rm -rf {} \;
  </code></pre>
  
  <p>Success, all <code>refs/</code> and their content are removed (If I don't use <code>-depth</code>, find will report an error that the dirs don't exists even though they were removed correctly).</p>
  
  <h3>Removing refs from Git</h3>
  
  <pre class="lang-bash prettyprint-override"><code>git filter-branch --index-filter \
  'find . -name refs -depth -exec git rm -rf --cached --ignore-unmatch {} \;' \
  --prune-empty --tag-name-filter cat -- --all
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Y5doo.png" alt="Removing directory refs from Git by rewriting the Git history"></p>
  
  <p>As can be seen in the picture (think of <code>temp/a</code> as <code>temp/foo</code>) the command runs through and rewrites all commits but no <code>refs/</code> are removed so somehow the output of the find is not returned to <code>filter-branch --index-filter</code> as expected.</p>
  
  <p>Similar things seem to work for others.<br>
  What am I missing?</p>
  
  <p>PS. Yes I've read hundreds of posts, articles etc for hours and hours about this but it doesn't work for me anyway.</p>