I realize that my question is very similar to How to list the parent commit of a stash in `git stash list` and Get git stash parent commit, but those had so many confusing, disparate responses that I'm asking my own question.
Let's assume that if I run git stash list
, I see stash@{0}: On featureX: someMessageHere
How can I reveal the hash of the commit that I was working from when I made that stash (which I guess could be considered a parent commit)?
I've seen so many different answers, and I'm confused about what these each do, how they are different, and which one is the answer to my question:
git show stash@{1}^
git log -1 commitish^
git log -1 stash@{0}^
git log -g --no-walk --parents refs/stash
git for-each-ref --format='%(refname:short)' --points-at $(git rev-parse refs/stash~1) refs/heads
git log -g --format="%gd %H" refs/stash |
while read name hash; do
printf "%s %s " $name $(git rev-parse --short $name^)
git log -1 --format=%s $hash
done
For extra context, this is the reason I'm asking.
The commit you are looking for is stash@{0}^
:
git show stash@{0}^
git log -1 --oneline stash@{0}^
git rev-parse stash@{0}^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With