GIT 在特定提交之前获取提交哈希 [英] GIT get the commit hash prior to a specific commit
问题描述
git 1.7.1
git show <hash>:<file>
根据提供的提交哈希给我文件
git show <hash>:<file>
gives me the file based on the commit hash provided
我正在试图弄清楚如何在我拥有的哈希之前打赌上一次提交的文件.
I am trying to figure out how to bet the file of the previous commit before the one who's hash I have.
我知道我总是可以使用 log
来获取所有哈希值并找出我需要的哈希值,但在我的情况下这不是一个好的解决方案,因为我试图尽量减少我需要的命令数量性能问题.
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.
想知道有没有简单的方法.
Was wondering if there is a simple way.
推荐答案
使用 git show HEAD^1
.您可以将 HEAD
替换为您的提交哈希
Use git show HEAD^1
. You can replace HEAD
with your commit-hash
如果您想查看提交哈希的所有父项,可以使用 git rev-list --parents -n 1 <commithash>
或使用 git show
正如@Bhaskar 在问题评论中所建议的那样.
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.
还有其他方法以及解释这里.
There are other ways as well as explained here.
这篇关于GIT 在特定提交之前获取提交哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!