title: How to stage a rename without subsequent edits in git?
body: <p>I have a file that I've renamed and then edited. I would like to tell Git to stage the rename, but not the content modifications. That is, I wish to stage the deletion of the old file name, and the addition of the old file contents with the new file name.</p>
  
  <p>So I have this:</p>
  
  <pre><code>Changes not staged for commit:
  
          deleted:    old-name.txt
  
  Untracked files:
  
          new-name.txt
  </code></pre>
  
  <p>but want either this:</p>
  
  <pre><code>Changes to be committed:
  
          new file:   new-name.txt
          deleted:    old-name.txt
  
  Changes not staged for commit:
  
          modified:   new-name.txt
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code>Changes to be committed:
  
          renamed:    old-name.txt -&gt; new-name.txt
  
  Changes not staged for commit:
  
          modified:   new-name.txt
  </code></pre>
  
  <p>(where the similarity measure should be 100%).</p>
  
  <p>I can't think of a straightforward way to do this.</p>
  
  <p>Is there syntax for getting the contents of a specific revision of a specific file, and adding this to the git staging area under a specified path?</p>
  
  <p>The delete part, with <code>git rm</code>, is fine:</p>
  
  <pre><code>$ git rm old-name.txt
  </code></pre>
  
  <p>It's the add part of the rename I'm struggling with. (I could save the new contents, checkout a fresh copy (for the old contents), <code>mv</code> in the shell, <code>git add</code>, and then recover the new contents, but that seems like a very long way around!)</p>
  
  <p>Thanks!</p>