3

有没有一种简单的方法可以切换回您最近在当前分支之前所在的分支?与命令行中的“cd -”相同的概念。

在多个分支上工作时,这可能很有用。

4

2 回答 2

3

做就是了:

git checkout -

注意破折号。这会检查您在当前分支之前所在的最新分支。

如您所见,语法类似于cd -

于 2013-04-16T16:59:51.800 回答
1

如果没有@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}".
于 2013-04-17T03:27:36.730 回答