title: Detach many subdirectories into a new, separate Git repository
body: <p>This question is based on <a href="https://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository">Detach subdirectory into separate Git repository</a> </p>
  
  <p>Instead of detaching a single subdirectory, I want to detach a couple. For example, my current directory tree looks like this:</p>
  
  <pre><code>/apps
    /AAA
    /BBB
    /CCC
  /libs
    /XXX
    /YYY
    /ZZZ
  </code></pre>
  
  <p>And I would like this instead:</p>
  
  <pre><code>/apps
    /AAA
  /libs
    /XXX
  </code></pre>
  
  <p>The <code>--subdirectory-filter</code> argument to <code>git filter-branch</code> won't work because it gets rid of everything except for the given directory the first time it's run. I thought using the <code>--index-filter</code> argument for all unwanted files would work (albeit tedious), but if I try running it more than once, I get the following message:</p>
  
  <pre><code>Cannot create a new backup.
  A previous backup already exists in refs/original/
  Force overwriting the backup with -f
  </code></pre>
  
  <p>Any ideas? TIA</p>