title: Git: Best way to add only some parts of a file from another branch?
body: <p>Let's say you have a branch <code>master</code> and another branch <code>production</code>, both containing a version of the file <code>prog.py</code>, as well as many other files.  Imagine that you modify many files in the production branch, including <code>prog.py</code>.  Now, what is the best way of having only <em>some</em> changes made on <code>prog.py</code> in the <code>production</code> branch be applied to its version in the <code>master</code> branch?</p>
  
  <p>I started moving to the <code>master</code> branch and importing the file from the <code>production</code> branch:</p>
  
  <pre><code>git checkout master
  git checkout production -- prog.py
  </code></pre>
  
  <p>because I was hoping to be able to do <code>git add -p</code> and select the changes by hand.  The problem is that <code>prog.py</code> is both in the working tree and in the index.  How can I remove it from the index without touching the working tree?</p>
  
  <p>Or is there a better way of choosing which changes in <code>prog.py</code> should be imported from the <code>production</code> branch into the <code>master</code> branch?</p>