Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>One simple example is git can automatically convert a merge into a "fast forward". For example, let's say I have a branch that looks like this:</p> <p>Master:</p> <p><code>A ---&gt; B ---&gt; C</code></p> <p>And I create a feature branch based on Master with new commits D and E.</p> <p>Feature:</p> <pre><code>A --- &gt; B ---&gt; C \ D ---&gt; E </code></pre> <p>In svn, when you merge the feature branch back into master, you must create an entirely new commit that applies the changes of D and E on Master. So, it looks like:</p> <pre><code>Master: A ---&gt; B ---&gt; C -----------------&gt; F Feature: \ / ---&gt; D ---&gt; E --&gt; </code></pre> <p>In git we have a choice of how to incorporate the branch feature into master. If we do a </p> <pre><code>git rebase feature </code></pre> <p>git will automatically recognize that this is a trivial merge and perform a fast-forward merge, which will add the new commits to the master branch. The result of the rebase is: </p> <p>Master:</p> <pre><code>A ---&gt; B ---&gt; C ---&gt; D ---&gt; E </code></pre> <p>Both the head of Master and Feature point at commit E (in other words, they look exactly the same). A fast-forward merge is similar to what happens when you do an update in svn.</p> <p>Additionally, you have the option of forcing git to create a merge commit. If instead we do:</p> <pre><code>git merge feature </code></pre> <p>git will create a merge commit. The result of the merge is:</p> <pre><code>Master: A ---&gt; B ---&gt; C -----------------&gt; F Feature: \ / ---&gt; D ---&gt; E --&gt; </code></pre> <p>Commit F is the combination of D and E. </p>
 

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