title: Git: Correct way to change Active Branch in a bare repository?
body: <p>I have a bare repository that's used as the central store for my project.  All the developers do <code>git clone &lt;repo&gt;</code> to share with it.  When they do the clone, they get a checkout of the master branch (unless they do <code>git clone -n</code>) because <code>repo.git/HEAD</code> contains <code>ref: refs/heads/master</code>, making this the <em>Active Branch</em>.</p>
  
  <p>The question is, how do I change the <em>Active Branch</em> properly?  I could simply hack the <code>repo.git/HEAD</code> file directly, but that seems nasty and, well, hacky.</p>
  
  <p>I tried doing <code>git checkout &lt;otherbranch&gt;</code> in the repo <code>.git</code> directory, but that failed because I wasn't in a work tree.</p>
  
  <p>I tried <code>git update-ref HEAD refs/heads/otherbranch</code> but that just updated refs/heads/master to be the same as refs/heads/otherbranch (okay, I did that one in a dummy repository, not my production one!)</p>
  
  <p>I tried <code>git update-ref --no-deref HEAD refs/heads/otherbranch</code> and that almost worked.  It updated the <code>HEAD</code> file, but it set it to the SHA1 of the commit pointed to by <code>refs/heads/otherbranch</code>.</p>
  
  <p>I'm testing with git version <code>1.7.0.2.msysgit.0</code>.</p>
  
  <p>I'm guessing there's no way to do this through <code>git push</code>, as allowing all and sundry to change your default branch seems a bit unsafe (!), but surely there's a better way to do it in the repo <code>.git</code> directory than directly hacking the <code>HEAD</code> file.</p>