title: Remove folder from git history: BFG tool deletes all branches
body: <p>I need to delete the folder cache from all branches. I'm using the BFG tool, however it removes all branches but master. Here's what I do.</p>
  
  <p>Step 1: Create a mirror from local clone (Verify that there is many branches in my local clone):</p>
  
  <pre><code>myuser:~/Repositories$ cd test.git
  myuser:~/Repositories/test.git$ git --bare init
  Initialized empty Git repository in /home/saman/Repositories/test.git/
  myuser:~/Repositories/test.git$ cd ../originalrepo
  myuser:~/Repositories/originalrepo$ git push -u origin --all
  Counting objects: 21103, done.
  Delta compression using up to 8 threads.
  Compressing objects: 100% (8071/8071), done.
  Writing objects: 100% (21103/21103), 1.84 GiB | 30.50 MiB/s, done.
  Total 21103 (delta 13017), reused 21101 (delta 13015)
  To ../test.git
   * [new branch]      idio-additive -&gt; idio-additive
   * [new branch]      idiosyncratic -&gt; idiosyncratic
   * [new branch]      lazy -&gt; lazy
   * [new branch]      list -&gt; list
   * [new branch]      master -&gt; master
   * [new branch]      retake -&gt; retake
   * [new branch]      variance -&gt; variance
  Branch idio-additive set up to track remote branch idio-additive from origin.
  Branch idiosyncratic set up to track remote branch idiosyncratic from origin.
  Branch lazy set up to track remote branch lazy from origin.
  Branch list set up to track remote branch list from origin.
  Branch master set up to track remote branch master from origin.
  Branch retake set up to track remote branch retake from origin.
  Branch variance set up to track remote branch variance from origin.
  </code></pre>
  
  <p>Step 2: Run BFG tool over mirror</p>
  
  <pre><code>myuser:~/Repositories/originalrepo$ cd ..
  myuser:~/Repositories$ java -jar bfg.jar test.git --delete-folders cache
  
  Using repo : /home/saman/Repositories/test.git
  
  Found 435 objects to protect
  Found 8 commit-pointing refs : HEAD, refs/heads/idio-additive, refs/heads/idiosyncratic, ...
  
  Protected commits
  -----------------
  
  These are your protected commits, and so their contents will NOT be altered:
  
   * commit fe37396b (protected by 'HEAD') - contains 284 dirty files : 
      - cache/steadyState_00504943e81e98a199dfe851738dc15bd31eaddba3dd76c81a99d3ff (300.7 KB)
      - cache/steadyState_05fabdf818d4dc580e4ffb4a2769439ab31c20d6f776a52f39f4c175 (300.7 KB)
      - ...
  
  WARNING: The dirty content above may be removed from other commits, but as
  the *protected* commits still use it, it will STILL exist in your repository.
  
  Details of protected dirty content have been recorded here :
  
  /home/saman/Repositories/test.git.bfg-report/2016-06-06/14-21-39/protected-dirt/
  
  If you *really* want this content gone, make a manual commit that removes it,
  and then run the BFG on a fresh copy of your repo.
  
  
  Cleaning
  --------
  
  Found 668 commits
  Cleaning commits:       100% (668/668)
  Cleaning commits completed in 564 ms.
  
  Updating 7 Refs
  ---------------
  
      Ref                        Before     After   
      ----------------------------------------------
      refs/heads/idio-additive | 2efcf23c | 644b46bf
      refs/heads/idiosyncratic | 581b1c65 | 67ba6839
      refs/heads/lazy          | 065720e5 | 5b7a5327
      refs/heads/list          | 6bf819c0 | 0aa8b0a5
      refs/heads/master        | fe37396b | cea32db5
      refs/heads/retake        | c94a42d8 | 5194e362
      refs/heads/variance      | 3c3c62d8 | f47432bf
  
  Updating references:    100% (7/7)
  ...Ref update completed in 22 ms.
  
  Commit Tree-Dirt History
  ------------------------
  
      Earliest                                              Latest
      |                                                          |
      ...........DDmmmmDDDDDDDDDDDDDDDDDmmDDDDDDDDDDDDDDDDDDDDDDDD
  
      D = dirty commits (file tree fixed)
      m = modified commits (commit message or parents changed)
      . = clean commits (no changes to file tree)
  
                              Before     After   
      -------------------------------------------
      First modified commit | 00d79c52 | b5d26c37
      Last dirty commit     | 2efcf23c | 644b46bf
  
  
  In total, 912 object ids were changed. Full details are logged here:
  
      /home/saman/Repositories/test.git.bfg-report/2016-06-06/14-21-39
  
  BFG run is complete! When ready, run: git reflog expire --expire=now --all &amp;&amp; git gc --prune=now --aggressive
  
  Has the BFG saved you time?  Support the BFG on BountySource:  
  
  
  myuser:~/Repositories$ cd test.git
  myuser:~/Repositories/test.git$ git reflog expire --expire=now --all &amp;&amp; git gc --prune=now --aggressive
  Counting objects: 3829, done.
  Delta compression using up to 8 threads.
  Compressing objects: 100% (3812/3812), done.
  Writing objects: 100% (3829/3829), done.
  Total 3829 (delta 2460), reused 838 (delta 0)
  </code></pre>
  
  <p>Step 3: Clone from the altered mirror, count number of branches</p>
  
  <pre><code>myuser:~/Repositories$ git clone test.git
  Cloning into 'test'...
  done.
  myuser:~/Repositories$ cd test
  myuser:~/Repositories/test$ git branch
  * master
  </code></pre>