I need to check if a file exists in the last commit ( HEAD ). I do it with
git cat-file -e HEAD:path/to/file
but I realized that this could be problematic if the file was moved or renamed. Is there a way to verify a file based on SHA? I tried
git cat-file -e SHA
but he seems to be looking for all the commits, not just the most recent ones.
Based on Alan Curry's Answer , it seems to work
git ls-tree -r HEAD | grep SHA
source share