title: Splitting many subdirectories into a new, separate Git repository
body: <p>This question is related to:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/2982055/detach-many-subdirectories-into-a-new-separate-git-repository">detach-many-subdirectories-into-a-new-separate-git-repository</a></li>
  <li><a href="https://stackoverflow.com/questions/21621136/git-subtree-and-multiple-directories">Git subtree and multiple directories</a></li>
  </ul>
  
  <p>Instead of detaching a single subdirectory, I want to detach a couple. For example, here is my folder structure:</p>
  
  <pre><code>/app1
    /file1
    /file2
    /folder1
    /folder2
  /app2
    /file3
    /file4
    /folder3
    /folder4
  /test
    /file5
    /file6
    /folder5
    /folder6
  /README.md
  /new_file
  </code></pre>
  
  <p>And I would like this instead:</p>
  
  <pre><code>/app1
    /file1
    /file2
    /folder1
    /folder2
  /app2
    /file3
    /file4
    /folder3
    /folder4
  </code></pre>
  
  <p>I have tried the below alternatives, and none have worked so far:</p>
  
  <pre><code>git filter-branch --index-filter 'git rm --cached -qr -- . &amp;&amp; git reset -q $GIT_COMMIT -- /app1/* app2/*' --prune-empty -- --all
  
  Error: 
      pathspec '.' did not match any files
  </code></pre>
  
  <p>Second Try: </p>
  
  <pre><code>git filter-branch --tree-filter "mkdir samples; mv app1 app2 samples/" HEAD
  
  Error:
     rename app1 to samples/app1: No such file or directory
     Same error for the second sub-directory
  </code></pre>
  
  <p>Any ideas?</p>