title: Copy multiple files and dirs from one git repo to another while keeping their original history
body: <p>My requirement: Break down one git repo, into multiple git repos, preserving the same directory structure as in the original repo, and preserve the commit history for the files that are copied to the new repo. 
  What I have tried already:</p>
  
  <ol>
  <li><p>First I tried <strong>git filter-branch --subdirectory-filter</strong> based on the suggestions in <a href="http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/" rel="nofollow noreferrer">http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/</a>
  Result: The history is maintained, but can be viewed only on running 
  git log --follow
  Also, the original commit history cannot be seen on Github. It just displays my merge commit as the only commit for that file, and does not display any previous commits. I can still live with this limitation and accept it as a solution. But another concern I have with this approach is that, for each folder and each file that I want to copy, I need to clone the original repo multiple times and also repeat all those 12 or 13 steps everytime. I would like to know if there is any simpler way of doing it, since I'm moving a lot of files around. Also, since the post is 5 years old, just wondering if newer easier solutions are available? (Surprisingly Google mostly shows this blog as the first search result)</p></li>
  <li><p>Next thing I tried was a comment on the earlier Greg Bayer's post <a href="http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/#comment-2685894846" rel="nofollow noreferrer">http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/#comment-2685894846</a>
  This solution made things a bit simpler by using <strong>git subtree split</strong> but the results were same as listed in the first case.</p></li>
  <li><p>Then I tried the <strong>git log --patch-with-stat</strong>  and <strong>git am</strong> option based on this answer <a href="https://stackoverflow.com/a/11426261/5497551">https://stackoverflow.com/a/11426261/5497551</a>
  Result: This usually gives errors on encountering a merge, while applying the patch. 
  I tried one of the suggestions to this answer of using <strong>-m --first-parent</strong> This resolved the errors but does not expand any merges into their commits, just lists the merge as a single commit. Hence most of the commit history is lost. 
  So I added another option of <strong>--3way</strong>. This went over and over through the commits, and did not lead to any acceptable solution.</p></li>
  </ol>
  
  <p>In conclusion, I would prefer using the 3rd solution, if only there was an option to have all the commits in a merge to be listed in the history of the new repo. Else I have to stick to the first solution which is a bit inconvenient and tedious in my situation. Any advice, help would be greatly appreciated.</p>
  
  <p>Thanks. </p>