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)
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 ^
. Alternatively, you could use git name-rev --name-only
, which will give a symbolic name for the revision (e.g. master~10
).