Reputation: 2221
Assume I want to refer to a the parent of youngest commit whose commit message contains 'foo'.
HEAD^{/foo}^
will do the job.
This can be slightly shortened to @^{/foo}^
(I think).
The <rev>^{/<text>}
construction has a simplified form, though: :/<text>
.
Is there any way to use the short form and still refer to the parent of the resulting commit?
Upvotes: 4
Views: 184
Reputation: 1327294
Following the git rev-parse
command, you can combine two of those in order to get the parent of a commit whose message match the regexp.
In a git bash, type:
git rev-parse $(git rev-parse :/<text>)^
Those are two commands:
git rev-parse :/<text>
git rev-parse $(...)^
The $()
will execute the first command git rev-parse
and give its result to the second command git rev-parse
.
That will get you the parent of the commit with a commit message matching <text>
.
This differ from using only one command with:
git rev-parse HEAD^{/<text>}^
Or in Windows CMD:
git rev-parse "@^{/<text>}^"
# or, more complex, as ^ is the windows escape sign:
git rev-parse ^@^^{/<text>}^^
Upvotes: 5