Git推动& POPD?即结账最后一个状态 [英] Git pushd & popd? I.e., checkout last state
问题描述
我尝试了 我试着写了一个Bash脚本,并且想要签出一个标签,然后结账回我开始的地方。 git co HEAD @ {1}
,但是当在master启动时,这会将我带回master的提交SHA,但具有detatched头。
有没有像 pushd
& popd
for Git?
git checkout -
。 < a href =http://git-scm.com/docs/git-checkout>从手册页:
作为一种特殊情况,第N个最后分支的@ { - N}语法
检查
分支(而不是分离)。您
也可以指定 - 与$ { - 1}同义的
。
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}".
这篇关于Git推动& POPD?即结账最后一个状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!