title: How do I revert `git fetch upstream; git merge upstream/master`?
body: <p>This question is different from other questions in that, I want to keep some commits while I revert some commits. </p>
  
  <p>Here 's my setup.</p>
  
  <pre><code>Upstream repo on github (public repo which I don't own)
  Personal repo on my server(git clone --bare $upstream)
  </code></pre>
  
  <p>My workflow was like this:</p>
  
  <pre><code>Need to customize my personal branch
     1. check out origin/master(Personal)
     2. make changes
     3. push to origin/master
  
  Need to get new feature or bug fix from the original author(github)
     1. git fetch upstream
     2. git merge upstream/master
  </code></pre>
  
  <p>Now I find upstream/master has a bug and want to revert,<br>
  How do I go back to the state before I fetch/merged upstream for the last time?</p>
  
  <p>Edit.</p>
  
  <p>Suppose </p>
  
  <blockquote>
    <ol>
    <li>I merged upstream </li>
    <li>I merged what a team member pushed to origin/master(Personal)</li>
    </ol>
  </blockquote>
  
  <p>Now I want to undo the step 1.  </p>
  
  <blockquote>
    <p>git reset --hard commit_sha_of_one_prior_the_merge_1</p>
    
    <p>(Although finding the sha is not easy. git log shows a lot of commit
    sha's of upstream, so it's not easy to find
    commit-sha-of_one_prior_the_merge_1 which is not of <code>upstream</code> but of
    <code>origin/master</code>)</p>
  </blockquote>
  
  <p>How do I keep the step 2 merge?</p>
  
  <p>Suppose a slightly more complex scenario</p>
  
  <blockquote>
    <ol>
    <li>I merged upstream</li>
    <li>I merged what another team member pushed to Personal</li>
    <li>I also pushed my work to Personal</li>
    </ol>
  </blockquote>
  
  <p>Now I want to undo the upstream merge.
  How can I do it?</p>