title: How to take an old version of git code and make it the latest
body: <p>Some one merged a non working code into git and there were couple check-ins after that. I have two options, 1. To revert changes one by one and then when I reach good code, stop there. Option 2. Branch out the clean version using the checkin sha and make it the head. I see the question <a href="https://stackoverflow.com/questions/4114095/how-to-revert-git-repository-to-a-previous-commit">posted here</a> and several other question. If I try option one, after couple resets when I try to reset next one I get:</p>
  
  <pre><code>On branch master
  Your branch is ahead of 'origin/master' by 3 commits.
    (use "git push" to publish your local commits)
  nothing to commit, working directory clean
  </code></pre>
  
  <p>Then I checked out the version I want to move to HEAD, and try to commit that. But I get this:</p>
  
  <pre><code>HEAD detached at 0c1b8c1
  nothing to commit, working directory clean
  </code></pre>
  
  <p>When I try option 2 get the correct version of the code, but when I try to commit, it says nothing to commit. What's the best way to take an old version of the code and make it the latest and greatest in GIT? This is what I'm trying to do:
  <a href="https://i.stack.imgur.com/rPPxd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rPPxd.jpg" alt="enter image description here"></a></p>