title: Git checkout commit, do stuff, and go back to master
body: <p>I have a build system that takes a git repository, goes back to a specific commit, and then uploads those files some where. Then is goes back to master.</p>
  
  <p>I'm unsure that I'm using the right Git commands, as Git will give me this message whenever I perform a <code>git checkout SHA</code>:</p>
  
  <pre><code>You are in 'detached HEAD' state. You can look around, make experimental
  changes and commit them, and you can discard any commits you make in this
  state without impacting any branches by performing another checkout.
  
  If you want to create a new branch to retain commits you create, you may
  do so (now or later) by using -b with the checkout command again. Example:
  
  git checkout -b new_branch_name
  </code></pre>
  
  <p>The only thing I want to do is to reset my working directory to a specific commit, upload those files, and go back to HEAD/master. I might make a few changes to files when I go to the specific commit SHA (convert XML to JSON or something), but I just want to loose all of those changes when I go back to master. Right now this is my code</p>
  
  <pre><code>git checkout SHA
  
  # do a bunch of conversion and uploading
  
  git checkout master
  </code></pre>
  
  <p>Is that the preferred way of doing what I want? Will I always be able to do pulls from the origin without getting any file conflicts (I don't want to keep whatever I'm doing between the checkouts)?</p>
  
  <p>I'm asking because I'm seeing "your master and origin/master diverged" some times, although I'm not sure it's caused by this.</p>
  
  <p>Thanks in advance.</p>