Git推& amp;弹出?即结帐上一个状态 [英] Git pushd & popd? I.e., checkout last state
本文介绍了Git推& amp;弹出?即结帐上一个状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个Bash脚本,我想签出一个标签,然后签出回到开始的地方.
I'm writing a Bash script, and I want to checkout a tag and then checkout back to where I started.
我尝试了 git co HEAD @ {1}
,但是当从master开始时,这使我回到了master的提交SHA,但是头部已分离.
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.
是否有类似 pushd
& popd
for Git?
Is there something like pushd
& popd
for Git?
推荐答案
git checkout @ {-1}
,可以缩写为 git checkout-
.
作为特殊情况,"@ {-N}"语法对于第N个最后一个分支签出分支(而不是分离).你也可以指定-这是同义词加上"@ {-1}".
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}".
这篇关于Git推& amp;弹出?即结帐上一个状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文