I am using below git command to get last 2 commit hash
git log -n 2 --pretty=format:"%H" #To get only hash value of commit
But I needs only second last commit hash.
Any help would be great
Thanks
I am using below git command to get last 2 commit hash
git log -n 2 --pretty=format:"%H" #To get only hash value of commit
But I needs only second last commit hash.
Any help would be great
Thanks
git rev-parse @~
rev-parse turns various notations into hashes, @ is current head, and ~ is the previous commit.
This generalizes to commits arbitrarily far back: for example, you can write @~3 (or @~~~) to specify "three commits before the current head".
Use skip attribute
--skip=<number> skips number commits before starting to show the commit output.
git log -n 1 --skip 1 --pretty=format:"%H"
Follow this link for more info on git log