title: How is the Git hash calculated?
body: <p>I'm trying to understand how Git calculates the hash of refs.</p>
  <pre><code>$ git ls-remote https://github.com/git/git  
  
  ....
  29932f3915935d773dc8d52c292cadd81c81071d    refs/tags/v2.4.2
  9eabf5b536662000f79978c4d1b6e4eff5c8d785    refs/tags/v2.4.2^{}
  ....
  </code></pre>
  <p>Clone the repo locally. Check the <code>refs/tags/v2.4.2^{}</code> ref by sha</p>
  <pre><code>$ git cat-file -p 9eabf5b536662000f79978c4d1b6e4eff5c8d785 
  
  tree 655a20f99af32926cbf6d8fab092506ddd70e49c
  parent df08eb357dd7f432c3dcbe0ef4b3212a38b4aeff
  author Junio C Hamano &lt;gitster@pobox.com&gt; 1432673399 -0700
  committer Junio C Hamano &lt;gitster@pobox.com&gt; 1432673399 -0700
  
  Git 2.4.2
  
  Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
  </code></pre>
  <p>Copy the decompressed content so that we can hash it. (AFAIK Git uses the uncompressed version when it's hashing)</p>
  <pre><code>git cat-file -p 9eabf5b536662000f79978c4d1b6e4eff5c8d785 &gt; fi
  </code></pre>
  <p>Let's SHA-1 the content using Git's own hash command</p>
  <pre><code>git hash-object fi
  3cf741bbdbcdeed65e5371912742e854a035e665
  </code></pre>
  <p>Why is the output not <code>[9e]abf5b536662000f79978c4d1b6e4eff5c8d785</code>? I understand the first two characters (<code>9e</code>) are the length in hex. How should I hash the content of <code>fi</code> so that I can get the Git ref <code>abf5b536662000f79978c4d1b6e4eff5c8d785</code>?</p>