I'm writing a Bash script, and I want to checkout a tag and then checkout back to where I started.
I tried git co HEAD@{1}
, but when starting at master, that takes me back to the commit SHA of master but with a detatched head.
Is there something like pushd
& popd
for Git?
git checkout @{-1}
which can be abbreviated to git checkout -
.
As a special case, the "@{-N}" syntax for the N-th last branch checks out the branch (instead of detaching). You may also specify - which is synonymous with "@{-1}".