Yes, you can take advantage that git IDs are checksums for objects. A commit checksum is the contents of the directory, which is good, but they're also the log message, date of the commit, and other things you can't reproduce.
Git also stores the contents of the directory (ie. all the files and directories) as a tree object. That also has an ID which is a checksum of the contents. Same contents, same checksum. You can reproduce this checksum. Here's how.
Initialize a new repository in your mystery directory. Add and commit all the files. Then check its tree hash with:
git log --pretty=format:'%T'
Then back in your real repository, search your history for a commit with the same tree.
git log --pretty=format:'ID: %H Tree: %T %s'
The caveat is that the mystery files have to be exactly the same and it has to have all the files. Even the .gitignore
. It also has to have the same permissions (though not the same owner).
Once you're done you can delete the .git
directory from the mystery repository, but more likely you should replace it with a clone and checkout the correct version.
If that doesn't work because the directories aren't exactly the same, you can use a similar technique to zero in on a range of commits by using the checksum of a single, important, often edited file (which git calls a "blob"). On your mystery repository, do
git hash-object <important file>
Then you can search your project history for that hash. That's covered in this answer.