`git switch -` 中的破折号是什么意思?
What does the dash mean in `git switch -`?
结帐时,我收到此消息:
$ git checkout HEAD~2
Note: switching to 'HEAD~2'.
You are in a 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits that you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
git switch -
中的破折号是什么意思?总是上一个分支吗?
git switch
的文档说明如下:
You can use the @{-N}
syntax to refer to the N-th last branch/commit switched to using "git switch
" or "git checkout
" operation. You may also specify -
which is synonymous to @{-1}
. This is often used to switch quickly between two branches, or to undo a branch switch by mistake.
因此,-
等同于 @{-1}
,它表示使用 git switch
或 git checkout
选择的最后一次提交。
结帐时,我收到此消息:
$ git checkout HEAD~2
Note: switching to 'HEAD~2'.
You are in a 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits that you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
git switch -
中的破折号是什么意思?总是上一个分支吗?
git switch
的文档说明如下:
You can use the
@{-N}
syntax to refer to the N-th last branch/commit switched to using "git switch
" or "git checkout
" operation. You may also specify-
which is synonymous to@{-1}
. This is often used to switch quickly between two branches, or to undo a branch switch by mistake.
因此,-
等同于 @{-1}
,它表示使用 git switch
或 git checkout
选择的最后一次提交。