title: git update-ref appears to do nothing
body: <p>At some point in the past someone deleted our <code>master</code> branch because we use <code>newmaster</code>. However, origin/HEAD is wrong:</p>
  
  <pre><code>$ cat .git/refs/remotes/origin/HEAD
  ref: refs/remotes/origin/master
  $ cat .git/refs/remotes/origin/master
  cat: .git/refs/remotes/origin/master: No such file or directory
  </code></pre>
  
  <p>This causes e.g. <code>git gc</code> to fail. I try to fix the situation like this:</p>
  
  <pre><code>git update-ref --create-reflog -m "Fix HEAD to be newmaster instead of non-existent master" refs/remotes/origin/HEAD refs/remotes/origin/newmaster refs/remotes/origin/master
  </code></pre>
  
  <p>This fails with <code>fatal: refs/remotes/origin/master: not a valid old SHA1</code>, so it seems that I cannot fix a broken reference with <code>update-ref</code> doing validation. If I remove the old value then I get no output and a zero return code. However, nothing happens: I see the same content in <code>origin/HEAD</code> and <code>git gc</code> still throws an error:</p>
  
  <pre class="lang-bash prettyprint-override"><code>$ cat .git/refs/remotes/origin/HEAD
  ref: refs/remotes/origin/master
  $ git gc
  fatal: bad object refs/remotes/origin/HEAD
  error: failed to run repack
  </code></pre>
  
  <p><strong>Questions:</strong></p>
  
  <ul>
  <li>what is the recommended way to fix this situation?</li>
  <li>are my syntax for <code>update-ref</code> and branch references correct?</li>
  <li>is either of the validation failure or the failure to act a bug in git?</li>
  </ul>