title: How can I merge a specific file from one branch into another branch in Git
body: <p>I have 2 branches in a git repo, lets call them, dev and test.  I have changes in a single file, somecode.js.  Both branches have changes to somecode.js.  The 2 branches have diverged significantly (but manageably) so a straight "merge" is insufficient.</p>
  
  <p>I have tried <a href="http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/">http://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/</a> but it doesn't merge the contents of both files.  You basically just write over the file instead of actually merging the contents of the file.</p>
  
  <p>I have also tried:</p>
  
  <pre><code>git checkout -b newbranch
  git checkout test somecode.js
  git commit -m "somecode changes from newbranch"
  git checkout dev
  git merge newbranch
  </code></pre>
  
  <p>And</p>
  
  <pre><code>git checkout -m test somecode.js
  </code></pre>
  
  <p>(I was really hopeful with the -m for merge, but it didn't appear to work for me...)</p>
  
  <p>I thought I was close to what I needed, but then I realized that it just fast-forwarded the commit meaning it didn't merge, it wrote over the original file in test.</p>
  
  <p>So, to reiterate, how can I merge a specific file from one branch into another branch without just writing over the file in the branch I am merging into using git.</p>