'View commit that will be referenced when using tilde ~ or caret ^ with HEAD?
Since Git operations must be done with precision, and commit histories can sometimes be complex, the use of caret and tilde can sometimes be a little precarious.
Is there a way we can see which commit will be referenced when using tilde or caret before attempting an operation in which they'll be used? Note: I'm aware of dry-run but I prefer something much simpler that just shows the referenced commit, if it exists.
Example
Suppose we have this commit history with parent commits ordered left-to-right:
G H I J
\ / \ /
D E F
\ | / \
\ | / |
\|/ |
B C
\ /
\ /
A
Suppose we want to reference commit F.
We could guess HEAD^2^1 should reference commit F.
Is there a Git command to see the commit/SHA/message for HEAD^2^1 so we can know for sure we're referencing the commit we intend to reference?
Desired output
I would hope to run something like this and receive back a commit that it references:
git <command> HEAD^2^1
commit 64ccfb82af41e92edc4118ed9736a49ffcca7679
Author: John Doe <[email protected]>
Date: Mon Dec 20 20:52:13 2021 +1100
Update api key usage
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
