title: Git cannot lock ref 'HEAD': unable to resolve reference HEAD
body: <p>I'm trying to commit the changes to my repository but I receive the error below:</p>
  
  <pre><code>git -c diff.mnemonicprefix=false -c core.quotepath=false commit -q -F C:\Users\Contronym\AppData\Local\Temp\bkdweixb.mnu
  fatal: cannot lock ref 'HEAD': unable to resolve reference HEAD: Invalid argument
  
  Completed with errors, see above.
  </code></pre>
  
  <p>I'm using bitbucket and SourceTree.</p>
  
  <p>What's the reason for this commit failing? I was able to commit just fine the last 3 commits over the past week. Then, all of a sudden, I receive this error.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I ran <code>git gc</code> and these are the results:</p>
  
  <pre><code>$ git gc
  error: bad ref for HEAD
  error: bad ref for HEAD
  error: inflate: data stream error (unknown compression method)
  fatal: loose object 53b65bd9b4fec7f6a7b0b3313c68199a18804327 (stored in .git/objects/53/b65bd9b4fec7f6a7b0b3313c68199a18804327) is corrupt
  error: failed to run repack
  </code></pre>
  
  <p>I checked the directory <code>.git/objects/53/b65bd9b4fec7f6a7b0b3313c68199a18804327</code> but that doesn't exist. There's two other files there, but <code>b65bd9b4fec7f6a7b0b3313c68199a18804327</code> doesn't exist.</p>