Skip to content

Commit 9e37969

Browse files
ohno418gitster
authored andcommitted
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 <[email protected]> Acked-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a38d39a commit 9e37969

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Documentation/git-checkout.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,9 @@ before that happens. If we have not yet moved away from commit `f`,
477477
any of these will create a reference to it:
478478

479479
------------
480-
$ git checkout -b foo <1>
481-
$ git branch foo <2>
482-
$ git tag foo <3>
480+
$ git checkout -b foo # or "git switch -c foo" <1>
481+
$ git branch foo <2>
482+
$ git tag foo <3>
483483
------------
484484

485485
<1> creates a new branch `foo`, which refers to commit `f`, and then

0 commit comments

Comments
 (0)