Git推动& POPD?即结账最后一个状态 [英] Git pushd & popd? I.e., checkout last state

查看:146
本文介绍了Git推动& POPD?即结账最后一个状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我尝试了 我试着写了一个Bash脚本,并且想要签出一个标签,然后结账回我开始的地方。 git co HEAD @ {1} ,但是当在master启动时,这会将我带回master的提交SHA,但具有detatched头。

有没有像 pushd & popd for Git?

解决方案 c> git checkout @ { - 1} 可缩写为 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 -.

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

这篇关于Git推动&amp; POPD?即结账最后一个状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆