How to get SHA of file for specific Git commit?

浪子不回头ぞ 提交于 2019-12-22 07:41:36

问题


Is there a way to get SHA of file for specific Git commit?

It's possible with 2 commands:

  1. retrieving file git show COMMIT_VERSION:myfile.txt > ~/tmp/myfile.txt
  2. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!