Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should look at leveraging the squash merge capability of git i.e. <code>git merge --squash</code>, so that you do not rewrite history unnecessarily.</p> <p>Both <code>git merge --squash</code> and <code>git rebase --interactive</code> can be used to produce a squashed commit with the same resultant work-tree, but they are intended to serve 2 totally different purposes. Your tree eventually ends up looking different in both the cases.</p> <p>Initial tree:</p> <pre><code>a -- b -- c -- d master \ \-- e -- f feature1 </code></pre> <p>After <code>git checkout master; git merge --squash feature1; git commit</code>:</p> <pre><code>a -- b -- c -- d -- F master \ \-- e -- f feature1 </code></pre> <p>After <code>git checkout master; git rebase -i feature1</code> and choosing to <code>pick c</code> and <code>squash d</code>:</p> <pre><code>a -- b /-- F master \ / \-- e -- f feature1 </code></pre> <p>As you can see from the difference, you do not rewrite the history of any branch when using <code>git merge --squash</code> but you end up rewriting the history of <code>master</code> when using <code>git rebase -i</code>.</p> <p>Also note that the actual commits (for the ones which got squashed) would be present in your git history in both the cases, only as long as you have some branch or tag reference through which those commits are reachable.</p> <p>In other words, in the above example, if you delete <code>feature1</code> after doing <code>merge --squash</code>, you would not be able to actually view the commits <code>e</code> or <code>f</code> in the future (especially after the 90 days reflog period). The same applies to the commits <code>c</code> and <code>d</code> in the <code>rebase</code> example.</p>
    singulars
    1. This table or related slice is empty.
    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.
    3. 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