Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you want to merge most but not all of the commits on branch "maint" to "master", for instance, you can do this. It requires some work---- as mentioned above, the usual use case is to merge everything from a branch--- but sometimes it happens that you made a change to a release version that shouldn't be integrated back (maybe that code's been superceded in master already), so how do you represent that? Here goes...</p> <p>So let's suppose maint has had 5 changes applied, and one of those (maint~3) is not to be merged back into master, although all the others should be. You do this in three stages: actually merge everything before that one, tell git to mark maint~3 as merged even when it isn't, and then merge the rest. The magic is:</p> <pre><code>bash &lt;master&gt;$ git merge maint~4 bash &lt;master&gt;$ git merge -s ours maint~3 bash &lt;master&gt;$ git merge maint </code></pre> <p>The first command merges everything <em>before</em> your troublesome maint commit onto master. The default merge log message will explain you're merging "branch 'maint' (early part)".</p> <p>The second command merges the troublesome maint~3 commit, but the "-s ours" option tells git to use a special "merge strategy" which, in fact, works by simply keeping the tree you are merging into and ignoring the commit(s) you are merging completely. But it does still make a new merge commit with HEAD and maint~3 as the parents, so the revision graph now says that maint~3 is merged. So in fact you probably want to use the -m option to 'git merge' as well, to explain that that maint~3 commit is actually being ignored!</p> <p>The final command simply merges the rest of maint (maint~2..maint) into master so that you're all synced up again.</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