We have a script that actually does git fetch; git checkout origin/
to deploy a certain feature. The reason why we do this is that we wan\'t to avoid
Here's git nthlastcheckout
, it gets the exact string you used (or everything after its last space) 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