Question
Is it possible to compute a git hash of a file or directory outside of and independent of any git repository?
Motivation
I want to use this method to identify differences in generated artifacts (e.g. css generated from sass).
The benefit of doing this with git would be that the hashes can be compared against existing file hashes in a git history, to see if they look familiar.
Background
In How to compute the git hash-object of a directory? we learn how to compute the git hash of a directory. This method only works if the directory is within a git repository.
git ls-files -s somedirectory | git hash-object --stdin
From my understanding of git, the git hash of a file or directory depends only on the file or directory contents, perhaps file perms, but not on anything in the repository.
Known methods
Yes we could temporarily create a repo, but why that extra step?