Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Starting with git 1.9/2.0 Q1 2014, you won't have to mark your previous branch origin before rebasing it on the rewritten upstream branch, as described in <a href="https://stackoverflow.com/users/9410/aristotle-pagaltzis">Aristotle Pagaltzis</a>'s <a href="https://stackoverflow.com/a/4084870/6309">answer</a>:<br> See <a href="https://github.com/git/git/commit/07d406b742b577a39d7cbdacd76d0dde021ff788" rel="nofollow noreferrer">commit 07d406b</a> and <a href="https://github.com/git/git/commit/d96855ff517560650c62eca51a8bb78263f6a3ef" rel="nofollow noreferrer">commit d96855f</a> :</p> <blockquote> <p>After working on the <code>topic</code> branch created with <code>git checkout -b topic origin/master</code>, the history of remote-tracking branch <code>origin/master</code> may have been rewound and rebuilt, leading to a history of this shape:</p> </blockquote> <pre><code> o---B1 / ---o---o---B2--o---o---o---B (origin/master) \ B3 \ Derived (topic) </code></pre> <blockquote> <p>where <code>origin/master</code> used to point at commits <code>B3</code>, <code>B2</code>, <code>B1</code> and now it points at <code>B</code>, and your <code>topic</code> branch was started on top of it back when <code>origin/master</code> was at <code>B3</code>. </p> <p><strong>This mode uses the reflog of <code>origin/master</code> to find <code>B3</code> as the fork point, so that the <code>topic</code> can be rebased on top of the updated <code>origin/master</code></strong> by:</p> </blockquote> <pre><code>$ fork_point=$(git merge-base --fork-point origin/master topic) $ git rebase --onto origin/master $fork_point topic </code></pre> <p>That is why the <a href="http://git-scm.com/docs/git-merge-base" rel="nofollow noreferrer"><code>git merge-base</code></a> command has a new option:</p> <pre><code>--fork-point:: </code></pre> <blockquote> <p>Find the point at which a branch (or any history that leads to <code>&lt;commit&gt;</code>) forked from another branch (or any reference) <code>&lt;ref&gt;</code>.<br> This does not just look for the common ancestor of the two commits, but <strong>also takes into account the reflog of <code>&lt;ref&gt;</code> to see if the history leading to <code>&lt;commit&gt;</code> forked from an earlier incarnation of the branch <code>&lt;ref&gt;</code></strong>.</p> </blockquote> <hr> <blockquote> <p>The "<code>git pull --rebase</code>" command computes the fork point of the branch being rebased using the reflog entries of the "<code>base</code>" branch (typically a remote-tracking branch) the branch's work was based on, in order to cope with the case in which the "base" branch has been rewound and rebuilt. </p> </blockquote> <p>For example, if the history looked like where:</p> <blockquote> <ul> <li>the current tip of the "<code>base</code>" branch is at <code>B</code>, but earlier fetch observed that its tip used to be <code>B3</code> and then <code>B2</code> and then <code>B1</code> before getting to the current commit, and </li> <li>the branch being rebased on top of the latest "base" is based on commit <code>B3</code>, </li> </ul> <p>it tries to find <code>B3</code> by going through the output of "<code>git rev-list --reflog base</code>" (i.e. <code>B</code>, <code>B1</code>, <code>B2</code>, <code>B3</code>) until it finds a commit that is an ancestor of the current tip "<code>Derived (topic)</code>".</p> <p>Internally, we have <code>get_merge_bases_many()</code> that can compute this with one-go.<br> We would want a merge-base between <code>Derived</code> and a fictitious merge commit that would result by merging all the historical tips of "<code>base (origin/master)</code>".<br> When such a commit exist, we should get a single result, which exactly match one of the reflog entries of "<code>base</code>".</p> </blockquote> <hr> <p>Git 2.1 (Q3 2014) will add make this feature more robust to this: see <a href="https://github.com/git/git/commit/1e0dacdbdb751caa5936b6d1510f5e8db4d1ed5f" rel="nofollow noreferrer">commit 1e0dacd</a> by <a href="https://github.com/johnkeeping" rel="nofollow noreferrer">John Keeping (<code>johnkeeping</code>)</a></p> <p>correctly handle the scenario where we have the following topology:</p> <pre><code> C --- D --- E &lt;- dev / B &lt;- master@{1} / o --- B' --- C* --- D* &lt;- master </code></pre> <p>where:</p> <ul> <li><code>B'</code> is a fixed-up version of <code>B</code> that is not patch-identical with <code>B</code>;</li> <li><code>C*</code> and <code>D*</code> are patch-identical to <code>C</code> and <code>D</code> respectively and conflict textually if applied in the wrong order;</li> <li><code>E</code> depends textually on <code>D</code>.</li> </ul> <p>The correct result of <code>git rebase master dev</code> is that <code>B</code> is identified as the fork-point of <code>dev</code> and <code>master</code>, so that <code>C</code>, <code>D</code>, <code>E</code> are the commits that need to be replayed onto <code>master</code>; but <code>C</code> and <code>D</code> are patch-identical with <code>C*</code> and <code>D*</code> and so can be dropped, so that the end result is:</p> <pre><code>o --- B' --- C* --- D* --- E &lt;- dev </code></pre> <p>If the fork-point is not identified, then picking <code>B</code> onto a branch containing <code>B'</code> results in a conflict and if the patch-identical commits are not correctly identified then picking <code>C</code> onto a branch containing <code>D</code> (or equivalently <code>D*</code>) results in a conflict.</p>
    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. This table or related slice is empty.
    1. 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