title: git check if file exists on HEAD with SHA?
body: <p>I need to check if a file exists on the most recent commit (<code>HEAD</code>). I have been doing this with</p>
  
  <pre><code>git cat-file -e HEAD:path/to/file
  </code></pre>
  
  <p>but I realized this could be problematic if the file has been moved or renamed. Is there a way to check a file based on the SHA? I tried</p>
  
  <pre><code>git cat-file -e SHA
  </code></pre>
  
  <p>but it seems to search all commits, not just the most recent.</p>
  
  <p>Based on <a href="https://stackoverflow.com/a/11327054">Alan Curry’s answer</a> this seems to work</p>
  
  <pre><code>git ls-tree -r HEAD | grep SHA
  </code></pre>