有没有一种简单的方法可以切换回您最近在当前分支之前所在的分支?与命令行中的“cd -”相同的概念。
在多个分支上工作时,这可能很有用。
做就是了:
git checkout -
注意破折号。这会检查您在当前分支之前所在的最新分支。
如您所见,语法类似于cd -
如果没有@KlasMellbourn 的回答,我永远不会找到这个,但这实际上是在git-checkout(1)手册页中提到的(在描述部分<branch>
):
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}".