git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] doc: use "git switch -c" rather than "git checkout -b" consistently

From
Yutaro Ohno via GitGitGadget <gitgitgadget@gmail.com>
Date
Jan 8, 2023, 08:24 UTC
Message-ID
<pull.1422.git.git.1673166241185.gitgitgadget@gmail.com>
From: Yutaro Ohno <yutaro.ono.418@gmail.com>

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>".

Use "git switch -c" and fix this inconsistency.
Signed-off-by: Yutaro Ohno <yutaro.ono.418@gmail.com>
---
    doc: use "git switch -c" rather than "git checkout -b" consistently
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1422%2Fohno418%2Fimprove-git-checkout-doc-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1422/ohno418/improve-git-checkout-doc-v1
Pull-Request: https://github.com/git/git/pull/1422
 Documentation/git-checkout.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 4cb9d555b4b..ba3d6164847 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -477,9 +477,9 @@ before that happens. If we have not yet moved away from commit `f`,
 any of these will create a reference to it:
 
 ------------
-$ git checkout -b foo   <1>
-$ git branch foo        <2>
-$ git tag foo           <3>
+$ git switch -c foo   <1>
+$ git branch foo      <2>
+$ git tag foo         <3>
 ------------
 
 <1> creates a new branch `foo`, which refers to commit `f`, and then

base-commit: 2b4f5a4e4bb102ac8d967cea653ed753b608193c
-- 
gitgitgadget
Next: Junio C Hamano
Message 1 of 14 in “doc: use "git switch -c" rather than "git checkout -b" consistently”
  1. doc: use "git switch -c" rather than "git checkout -b" consistentlyYutaro Ohno via GitGitGadget, Jan 8, 2023
  2. Junio C HamanoJan 9, 2023
  3. Eric SunshineJan 9, 2023
  4. Junio C HamanoJan 9, 2023
  5. Eric SunshineJan 9, 2023
  6. Yutaro OhnoJan 9, 2023
  7. rsbecker@nexbridge.comJan 9, 2023
  8. Eric SunshineJan 9, 2023
  9. rsbecker@nexbridge.comJan 9, 2023
  10. Eric SunshineJan 9, 2023
  11. Ævar Arnfjörð BjarmasonJan 9, 2023
  12. doc: add "git switch -c" as another option on detached HEADYutaro Ohno via GitGitGadget, Jan 9, 2023
  13. Eric SunshineJan 9, 2023
  14. Junio C HamanoJan 13, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.