doc: add "git switch -c" as another option on detached HEAD

In the "DETACHED HEAD" section in the git-checkout doc, it suggests
using "git checkout -b <branch-name>" to create a new branch on the
detached head.

On the other hand, when you checkout a commit that is not at the tip of
any named branch (e.g., when you checkout a tag), git suggests using
"git switch -c <branch-name>".

Add "git switch -c" as another option and mitigate this inconsistency.

Signed-off-by: Yutaro Ohno <yutaro.ono.418@gmail.com>
Acked-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Yutaro Ohno 2023-01-09 10:47:17 +00:00 committed by Junio C Hamano
parent a38d39a4c5
commit 9e37969e4b

View File

@ -477,7 +477,7 @@ before that happens. If we have not yet moved away from commit `f`,
any of these will create a reference to it: any of these will create a reference to it:
------------ ------------
$ git checkout -b foo <1> $ git checkout -b foo # or "git switch -c foo" <1>
$ git branch foo <2> $ git branch foo <2>
$ git tag foo <3> $ git tag foo <3>
------------ ------------