title: git move directory to another repository while keeping the history
body: <p>First - apologies for asking this question. There are a lot of topics about it already. But I'm not having much luck with them. My lack of familiarity with git is not much help.</p>
  
  <p>I'm moving a folder from one git repo to another (which already exists). e.g.</p>
  
  <pre><code>repo-1
  ---- dir1
  ---- dir2
  ---- dir3
  ---- dir-to-move
  ---- dir5
  
  repo-2
  ---- dir1
  ---- dir2
  ---- dir3
  </code></pre>
  
  <p>In the end I want the repos to look like</p>
  
  <pre><code>repo-1
  ---- dir1
  ---- dir2
  ---- dir3
  ---- dir-to-move
  ---- dir5
  
  repo-2
  ---- dir1
  ---- dir2
  ---- dir3
  ---- dir-to-move
  </code></pre>
  
  <p>i.e. For a time <em>dir-to-move</em> will exist in both repos. But eventually I'll migrate the latest changes to <em>repo-2</em> and remove <em>dir-to-move</em> from <em>repo-1</em>. </p>
  
  <p>My initial research made me believe that I needed to use <em>filter-branch</em>. e.g.</p>
  
  <p><a href="https://stackoverflow.com/questions/28830916/how-to-move-files-from-one-git-repo-to-another-preserving-history-using-git-for">How to move files from one git repo to another preserving history using `git format-patch`and `git am`</a></p>
  
  <p>I've since learnt that <em>subtree</em> superseded that approach. However it's not doing what I expected. I thought I'd be able to do something like</p>
  
  <p>In <em>repo-1</em> workspace</p>
  
  <pre><code>git subtree split -P dir-to-move -b split
  </code></pre>
  
  <p>to filter the <em>split</em> branch down to only <em>dir-to-move</em> and it's history.
  Then in <em>repo-2</em> workspace</p>
  
  <pre><code>git remote add repo-1 repo-1-url.git
  git subtree add --prefix dir-to-move split
  </code></pre>
  
  <p>This does move the code across. It also, sort of, includes the history</p>
  
  <p>e.g.</p>
  
  <pre><code>cd repo-2
  git log
  </code></pre>
  
  <p>Shows commits from <em>repo-1</em></p>
  
  <p>but</p>
  
  <pre><code>cd repo-2
  git log dir-to-move
  </code></pre>
  
  <p>Shows only an 'Add dir-to-move from commit ....'</p>
  
  <p>i.e. The history is included but does not show up when checked for the specific files/directories.</p>
  
  <p>How can I do this properly?</p>