Rebase only part of a branch
<p>I've got two branches (and master). Branch 2 is based on Branch 1 is based on master. I've submitted Branch 1 for review, it had some changes, I rebased some of those changes into history and merged the result into master. </p>

<p>Now I need to rebase Branch 2 on top of master to prepare it for review/merge.</p>

<p>The problem is that Branch 2 still contains the original commits of Branch 1, which don't exist anymore, so git gets confused. I tried rebase -i to drop the original commits of Branch 1, but the commits of Branch 2 don't base on top of master-before-branch-1.</p>

<p>What I need to do is take branch 2, drop some commits, and rebase just the remaining commits on top of master in a single operation. But I only know how to do these two operations in two distinct steps.</p>

<p>How can I rebase part of my branch onto another branch, dropping all commits that are not in common ancestry, except the ones I specify (e.g. from HEAD~2 up)?</p>

<p>Here's the current state:</p>

<pre><code>master                     new branch 1
- - - - - - - - - - - | - - - - - - - - -
    \
     \   branch 1
      \ _ _ _ _ _ _ _
                     \
                      \     branch 2
                       \ _ _ _ _ _ _ _
</code></pre>

<p>What I want to end up with:</p>

<pre><code>master            new branch 1    
- - - - - - - | - - - - - - - - - -
                                   \
                                    \
                                     \
                                      \    branch 2
                                       - - - - - - - - - 
</code></pre>