GIT在特定提交之前获取提交哈希 [英] GIT get the commit hash prior to a specific commit

查看:381
本文介绍了GIT在特定提交之前获取提交哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git 1.7.1



git show< hash>:< file> 基于所提供的提交散列

我试图弄清楚如何在前一次提交的文件之前下注我的散列。



我知道我总是可以使用 log 来获得所有散列并找出我需要的散列,但这不是我的情况的好解决方案因为我想尽量减少我需要为性能问题所做的命令。



想知道是否有简单的方法。

解决方案使用 git show HEAD ^ 1 。您可以使用您的提交哈希来替换 HEAD

编辑可以考虑多个父母:



如果你想查看所有父母的提交散列,你可以使用 git rev-list --parents -n 1< commithash> 或使用 git show 作为@Bhaskar在问题的评论中提出的建议。



其他方式以及此处

git 1.7.1

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.

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.

解决方案

Use git show HEAD^1. You can replace HEAD with your commit-hash

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.

The are other ways as well as explained here.

这篇关于GIT在特定提交之前获取提交哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆