Git pushd & popd? I.e., checkout last state

后端 未结 3 1270
旧时难觅i
旧时难觅i 2021-02-04 07:28

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, th

3条回答
  •  逝去的感伤
    2021-02-04 08:29

    git checkout @{-1} which can be abbreviated to git checkout -.

    From the manpage:

    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}".

提交回复
热议问题