title: git: how to create branch from commits and revert the commits?
body: <p>I have this scenario:</p>
  
  <ul>
  <li>I created a series of commits and pushed to the central repository. Others have pushed their own commits. So the history is (Myx are my commits, Ox are others' commits):</li>
  </ul>
  
  <blockquote>
  <pre><code>master ...-&gt;My1--&gt;My2--&gt;O1--&gt;O2
  </code></pre>
  </blockquote>
  
  <ul>
  <li>Now I've found a serious bug in my commits. I want to create a branch and revert my commits. This creates this history (Myx' are the reverting commits, O3 is another commit by others):</li>
  </ul>
  
  <blockquote>
  <pre><code>master ...-&gt;My1--&gt;My2--&gt;O1--&gt;O2--My1'--&gt;My2'--&gt;O3
                      \
                  fix  \--
  </code></pre>
  </blockquote>
  
  <p>The problem is that if I now merge <code>master</code> to <code>fix</code>, then this will merge My1' and My2' which will revert the code in fix, which is not what I want.</p>
  
  <p>What is the proper way to handle this scenario? My current approach would be to cherry-pick O1,O2,O3, but this sounds too manual &amp; error prone, so I'm looking if there is a better way (maybe another way to create the branch &amp; revert the commits to begin with?). I can't rewrite the history, since everything is already in the central repository </p>
  
  <p>UPDATE: to emphasize, the scenario is that the bug is a blocker and cannot be easily fixed. The feature is also not something that can be toggled in code. So reverting the feature in master is a must to get the code base back to working properly. </p>