I can find the current git branch name by doing either of these:
git branch | awk \'/^\\*/ { print $2 }\'
git describe --contains --all HEAD
<
Here's git nthlastcheckout
, it gets the exact string you used for your nth last checkout from the reflog:
git config --global alias.nthlastcheckout '!nthlastcheckout'"() {
git reflog |
awk '\$3==\"checkout:\" {++n}
n=='\${1-1}' {print \$NF; exit}
END {exit n!='\${1-1}'}'
}; nthlastcheckout \"\$@\""
Examples:
$ git nthlastcheckout
master
$ git nthlastcheckout 2
v1.3.0^2