[英]Finding a revision by commit message
I know this kind of thing gets asked a lot (for example here ), but (maybe because of this) I have not been able to find what I'm looking for. 我知道这类事情经常被问到(例如在这里 ),但是(也许正因为如此)我无法找到我想要的东西。
I know that I can specify a commit by a pattern matching its commit message, instead of by its hash, like this: 我知道我可以通过匹配其提交消息的模式来指定提交,而不是通过其哈希来指定,如下所示:
git show ":/rename function X to function Y"
This shows me the most recent commit whose message starts with the given pattern, without me having to search for its hash first. 这向我显示了最新提交,其消息以给定模式开头,而无需我首先搜索其哈希值。
My questions are: 我的问题是:
What is the name of this feature, and where is it documented? 此功能的名称是什么,在哪里记录? (searching Google for :/
is futile) (在Google中搜索:/
是徒劳的)
How can I get the parent of that commit? 如何获得该提交的父项? This does not work: 这不起作用:
git show ":/pattern"^
It's a bit ugly, and there may be a better way, but you could use something like the following to find the parent: 这有点丑陋,也许有更好的方法,但是您可以使用类似以下的方法来找到父对象:
git show $(git rev-parse ":/pattern")^
git rev-parse
gives the SHA1 for the specified revision, to which you can apply operators such as ^
. git rev-parse
给出指定版本的SHA1,您可以在其中应用诸如^
运算符。 Alternatively, you could use git name-rev --name-only
, which will give a symbolic name for the revision (eg master~10
). 或者,您可以使用git name-rev --name-only
,这将为修订提供符号名称(例如master~10
)。
:/
语法似乎没有专用名称,并在gitrevisions(7)手册页中进行了说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.