title: Why does a rebase after a cherry-pick not apply the same commit twice?
body: <p>When you cherry  pick a commit from one branch (say "topic") to another (lets call it "master") the history of that commit is rewritten, its hash changes and it effectively becomes a new, independent, commit.</p>
  
  <p>However when you subsequently rebase topic against master git is clever enough to know not to apply to the commit twice.</p>
  
  <p>Example:</p>
  
  <pre><code>A --- B &lt;- master
        \
         \---- C ---- D &lt;- topic
  
  $ git checkout master
  $ git cherrypick D
  
  A --- B --- D' &lt;- master
        \
         \---- C ---- D &lt;- topic
  
  $ git checkout topic
  $ git rebase master
  First, rewinding head to replay your work on top of it...
  Applying 'C'
  
  A --- B --- D' &lt;- master
              \
               \---- C' &lt;- topic
  </code></pre>
  
  <p>How does this magic work? Ie. how does git know it should apply C to D', but not D to D'?</p>