title: Python subprocess git checkout returns error even if there is no error
body: <p>I am writing a script to automate some GIT tasks. I know about GITPython but I prefer not using that. Even tough it may be easier.</p>
  
  <p>I got the following piece of code:</p>
  
  <pre><code>def executeCommand(cmd):
      p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
      out, error = p.communicate()
      if not error:
          return out.strip()
      else:
          print repr(out)
          print repr(error)
          print "Stopping execution!\r"
          exit(0)
  </code></pre>
  
  <p>This piece of code given the command <code>['git', 'checkout', 'master']</code> does indeed checkout the master. BUT it will stop executing, apparently because the error variable is not empty. I tried to print the outputs on error which is the following:</p>
  
  <pre><code>"Your branch is up-to-date with 'origin/master'.\n"
  "Switched to branch 'master'\n"
  Stopping execution!
  </code></pre>
  
  <p>As you can see, it succesfully checked out the master branch (Also verified by <code>git status</code>). But why is the second line filled in the error variable? How to handle this? Or is there no way of correctly handling this? Or should i not do any error checking? What is the best solution/explaination for this?</p>
  
  <p>Thanks!</p>