Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I assume <code>C</code> is a merge commit, and that's the reason you don't want to have it in your result.</p> <p>What you need, to do what you want, is <a href="http://git-scm.com/docs/git-rebase" rel="noreferrer" title="git-rebase(1) manual page">git rebase</a></p> <p>Let's start of with yet another schematic commit graph. To leave the original branches intact we will operate on a new branch called <code>rebasing</code></p> <pre><code>git checkout -b rebasing master --&gt; A --&gt; B------------------- --&gt; C --&gt; D (branch master) (branch rebasing) \ / +----+-&gt; F --&gt; G --&gt; H -+ (branch topic) </code></pre> <p>Just rebase everything between <code>topic</code> and <code>rebasing</code> onto <code>topic</code>.</p> <pre><code>git rebase --onto topic topic rebasing </code></pre> <p>or do the same with a shorter command</p> <pre><code>git rebase topic -&gt; A -&gt; B -----------------&gt; C -&gt; D (branch master) \ / +---+&gt; F -&gt; G -&gt; H + (branch topic) \ +---------&gt; B -&gt; D (branch rebasing) </code></pre> <p>Now when we just look at <code>rebasing</code> we have a straight line form <code>A</code> to <code>D</code>.</p> <pre><code>-&gt; A -&gt; F -&gt; G -&gt; H -&gt; B -&gt; D (branch rebasing) </code></pre> <p>So, the only problem right now might be that the order is different from what you expected. You could easily fix that by reordering commits with <code>git rebase --interactive</code>, if you want to.</p> <p>Or you rebase everything in a slightly more complicated way. Let's start again.</p> <pre><code>--&gt; A --&gt; B------------------- --&gt; C --&gt; D (branch master) (branch rebasing) \ / +----+-&gt; F --&gt; G --&gt; H -+ (branch topic) </code></pre> <p>First take everything from <code>C</code> to the tip of <code>master</code> (aka. <code>D</code>) and put it on the tip of <code>topic</code> (aka. <code>H</code>) :</p> <pre><code>git rebase --onto topic C master -&gt; A -&gt; B ----------------&gt; C -&gt; D (branch master) \ / +----&gt; F -&gt; G -&gt; H + (branch topic) \ +---------&gt; D (branch rebasing) </code></pre> <p>One last rebase, at the end, and we are finished.</p> <pre><code>git rebase B +----&gt; F -&gt; G -&gt; H + (branch topic) / \ -&gt; A -&gt; B ----------------&gt; C -&gt; D (branch master) \ +------------------------&gt; F -&gt; G -&gt; H -&gt; D (branch rebasing) </code></pre> <p>Voila!</p> <pre><code>-&gt; A -&gt; B -&gt; F -&gt; G -&gt; H -&gt; D (branch rebasing) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload