GIT 在特定提交之前获取提交哈希
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25664323/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
GIT get the commit hash prior to a specific commit
提问by transilvlad
git 1.7.1
混帐 1.7.1
git show <hash>:<file>
gives me the file based on the commit hash provided
git show <hash>:<file>
根据提供的提交哈希给我文件
I am trying to figure out how to bet the file of the previous commit before the one who's hash I have.
我想弄清楚如何在我拥有的哈希值之前对上一个提交的文件下注。
I know I can always use the log
to get all hashes and figure out the one i need but that's not a good solution in my case as I am trying to minimise the number of commands I need to do for performance issues.
我知道我总是可以使用log
来获取所有散列并找出我需要的散列,但这对我来说不是一个好的解决方案,因为我试图最大限度地减少我需要为性能问题执行的命令数量。
Was wondering if there is a simple way.
想知道有没有简单的方法。
回答by Nikhil Gupta
Use git show HEAD^1
. You can replace HEAD
with your commit-hash
使用git show HEAD^1
. 你可以HEAD
用你的提交哈希替换
Edit to take multiple parents into account:
编辑以考虑多个父母:
In case you want to see all the parents for a commit hash, you can use git rev-list --parents -n 1 <commithash>
or use git show
as @Bhaskar suggested in the comments to the question.
如果您想查看提交哈希的所有父项,您可以使用git rev-list --parents -n 1 <commithash>
或git show
按照问题评论中的@Bhaskar 建议使用。
There are other ways as well as explained here.
还有其他方法以及解释here。