title: Merge git repositories without common history, but with common files
body: <p>I have to merge two separate git repositories ORIG and WORK. WORK was created as a derivative of a subdirectory of ORIG, with some experimental changes that haven't been commited to ORIG. </p>
  
  <pre><code>~&gt; mkdir WORK
  ~&gt; cp -a ORIG/src/* WORK
  ~&gt; cd WORK
  ~/WORK&gt; # apply some experimental changes to WORK
  ~/WORK&gt; git init
  ~/WORK&gt; git add .
  ~/WORK&gt; git commit -m "Entirely disconnected commit."
  </code></pre>
  
  <p>As a result, WORK doesn't know that it originated from ORIG, and lacks the <code>src</code> prefix of the file names.</p>
  
  <p>Is it somehow possible to</p>
  
  <ul>
  <li>identify the commit in ORIG from which WORK was created and</li>
  <li>change WORK such that the full file paths 
  (i.e. <code>./src/FILE</code> instead of <code>./FILE</code>) are present,</li>
  <li>merge the repositories back together without losing history?</li>
  </ul>
  
  <p>Currently I've solved the problem by </p>
  
  <ul>
  <li><code>git mv</code>'ing each file in WORK to a newly created <code>./src</code> directory, </li>
  <li>adding ORIG as a remote,</li>
  <li><p>merging <code>ORIG/master</code> into WORK's <code>master</code> </p>
  
  <pre><code>git merge -X theirs --allow-unrelated-histories ORIG/master
  </code></pre>
  
  <p>with the <code>theirs</code> merge strategy, and reapplying 
  changes by hand, using <code>git diff</code> to find the relevant parts,</p></li>
  </ul>
  
  <p>but the result is an unclean history at best:</p>
  
  <ul>
  <li>The history doesn't represent the common ancestry of WORK and ORIG commits.</li>
  <li>In the history of WORK, the files appear in the root directory 
  instead of in <code>./src</code> and files from outside <code>./src</code> don't exist in the
  history of WORK at all.</li>
  </ul>
  
  <p>How would I produce a clean, merged history?</p>