Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For the record, here are the two solutions I am finally using based on the <a href="https://stackoverflow.com/a/16691308/1163698">answer of Craig Otis here</a> pointing at the <a href="https://stackoverflow.com/a/4991675/1163698">answer of lindes on "Finding a branch point with Git"</a>, using Bash aliases the ".gitconfig" file (tested under Linux Ubuntu 12.10)</p> <p>Initial state, <strong>where the branch "fix/123" has already been merged back into "master"</strong>:</p> <pre><code> I--J (stable) / - A - B - C - D - E - F - G (master) \ / X - Y (fix/123) </code></pre> <hr> <p><strong>1) To rebase the branch "fix/123" starting from "master" onto "stable"</strong> (this is a <strong>generic answer</strong> for most people reading this):</p> <p>Add the following Bash aliases into your ".gitconfig" file:</p> <pre><code>[alias] oldest-ancestor = !bash -c 'diff -u &lt;(git rev-list --first-parent "${1:-master}") &lt;(git rev-list --first-parent "${2:-HEAD}") | sed -ne \"s/^ //p\" | head -1' - rebase-onto = !bash -c 'git rebase --onto $1 `git oldest-ancestor $2 $3` $3' - </code></pre> <p>Then use the command line:</p> <pre><code>git rebase-onto stable master fix/123 </code></pre> <p>And here you are:</p> <pre><code> I--J (stable) / \ / X'- Y' (fix/123) / - A - B - C - D - E - F - G (master) \ / X - Y </code></pre> <hr> <p><strong>2) To rebase the branch "fix/123" starting from "master", creating a new branch "fix/123-stable" onto "stable"</strong> (this is the more specific answer I am going to use).</p> <p>Add the following Bash aliases into your ".gitconfig" file:</p> <pre><code>[alias] oldest-ancestor = !bash -c 'diff -u &lt;(git rev-list --first-parent "${1:-master}") &lt;(git rev-list --first-parent "${2:-HEAD}") | sed -ne \"s/^ //p\" | head -1' - rebase-onto = !bash -c 'git branch $4 $2 &amp;&amp; git rebase --onto $3 `git oldest-ancestor $1 $4` $4' - </code></pre> <p>Then use the command line:</p> <pre><code>git rebase-onto master fix/123 stable fix/123-stable </code></pre> <p>And here you are:</p> <pre><code> I--J (stable) / \ / X'- Y' (fix/123-stable) / - A - B - C - D - E - F - G (master) \ / X - Y (fix/123) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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