问题
Is there a way to get SHA of file for specific Git commit?
It's possible with 2 commands:
- retrieving file
git show COMMIT_VERSION:myfile.txt > ~/tmp/myfile.txt
- calculating SHA
git hash-object ./tmp/myfile.txt
But, maybe there's specific command in Git that does exactly that?
回答1:
git ls-tree COMMIT_VERSION myfile.txt
appears to contain the same result in its third field.
来源:https://stackoverflow.com/questions/12017185/how-to-get-sha-of-file-for-specific-git-commit