title: How to know what branch I am on git when checkout origin/<branch>
body: <p>We have a script that actually does <code>git fetch; git checkout origin/&lt;branch&gt;</code> to deploy a certain feature. The reason why we do this is that we wan't to avoid local branches (it's a test server), so the script just fetch the latest changes and checkout into it, then reloads the server.</p>
  
  <p>We also generate a log describing every deploy made, to bt sent by email to someone and archive. It's interesting that we send also the branch deployed, but the problem is when we do <code>checkout origin/&lt;branch&gt;</code>, we're changing to a <a href="http://git-scm.com/docs/git-checkout" rel="nofollow noreferrer">detached head</a>. I read <a href="https://stackoverflow.com/a/2743827/1390427">some answers</a> with a similar question, but nothing so specific.</p>
  
  <p>Is there a way to print what branch I am in this case (regardless user input, of course)?</p>