本文介绍了如何为特定的Git提交获取文件的SHA?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有两种方法可以获得文件的SHA:
- 检索文件
git show COMMIT_VERSION:myfile.txt> 〜/ tmp / myfile.txt
- 计算SHA
git hash-object ./tmp/myfile.txt
但是,也许Git中有特定的命令可以做到这一点?
> git ls-tree COMMIT_VERSION myfile.txt 在其第三个字段中包含相同的结果。
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?
解决方案
git ls-tree COMMIT_VERSION myfile.txt
appears to contain the same result in its third field.
这篇关于如何为特定的Git提交获取文件的SHA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
08-19 08:29