title: How does `git rebase` skip the commit which its change already has in upstream?
body: <p><a href="https://git-scm.com/docs/git-rebase" rel="noreferrer">git-rebase document</a> says:</p>
  
  <blockquote>
    <p>If the upstream branch already contains a change you have made (e.g., because you mailed a patch which was applied upstream), then that commit will be skipped.</p>
  </blockquote>
  
  <p>But how does Git do that?</p>
  
  <p>Assume any commit <code>X</code> is the parent of commit <code>Y</code>, and <code>diffXY</code> is the result of <code>git diff X Y</code> command. And I have following commits:</p>
  
  <pre><code>o---o---o        &lt;- master
   \
    o---o---o---o  &lt;- test &lt;- HEAD
  </code></pre>
  
  <p>If I do a <code>git rebase master</code>. Then I guess Git does the skipping commit already have in <code>master</code> by skipping any commit <code>Y</code> in <code>test</code> that <code>diffXY</code> already have in <code>master</code>.</p>
  
  <p>I've ran some examples and they were like what I guessed.</p>
  
  <p>This is just my guess, am I right?</p>
  
  <p>Plus, does Git do this skipping task before Git do the reapplying <code>test</code>'s commits onto the <code>master</code>?</p>