title: Undo a Git merge, but keep later changes, and rewrite history
body: <p>I have a bunch of branches, each with different features. Usually I'll have some extra branch "not_master" which contains master+feature A like so: </p>
  
  <pre><code>(not_master)     a--b--c--d--e---M--x--y--z
  (feature A)           --h--i--j-/
  </code></pre>
  
  <p>Sometimes I want to unmerge feature A, but keep commits <code>x,y,z</code> in "not_master".</p>
  
  <p>In other words, I would like this: </p>
  
  <pre><code>(not_master)     a--b--c--d--e--x--y--z
  </code></pre>
  
  <p>I see that I can do a <code>git revert -m 1 M</code> which will add a commit to the end that reverts my changes, but I don't really want to do that since these commits haven't been published yet so adding more commits makes the history even harder to read.</p>
  
  <p>Others suggest just doing a <code>git reset --hard M</code>, but that will dump the changes of <code>x,y,z</code>. Am I just thinking about this the completely wrong way? Should I just <code>git reset --hard M</code> and cherry pick x,y,z?</p>