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

[PATCH] fix suggested branch creation command when detaching head

From
Nicolas Pitre <nico@cam.org>
Date
Jan 26, 2007, 16:50 UTC
Message-ID
<Pine.LNX.4.64.0701261120020.3021@xanadu.home>
Doing:
$ git checkout HEAD^
Generates the following message:
|warning: you are not on ANY branch anymore.
|If you meant to create a new branch from the commit, you need -b to
|associate a new branch with the wanted checkout.  Example:
|  git checkout -b <new_branch_name> HEAD^

Of course if the user does as told at this point the created branch won't be located at the expected commit. Reword this message a bit to avoid such confusion.

Signed-off-by: Nicolas Pitre <nico@cam.org>
---
diff --git a/git-checkout.sh b/git-checkout.sh
index c52f352..1929424 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -156,9 +156,9 @@ then
 	if test -n "$oldbranch"
 	then
 		detach_warn="warning: you are not on ANY branch anymore.
-If you meant to create a new branch from the commit, you need -b to
-associate a new branch with the wanted checkout.  Example:
-  git checkout -b <new_branch_name> $arg"
+If you meant to create a new branch from this checkout, you may still do
+so (now or later) by using -b with the checkout command again.  Example:
+  git checkout -b <new_branch_name>"
 	fi
 elif test -z "$oldbranch" && test -n "$branch"
 then
Message 1 of 1 in “fix suggested branch creation command when detaching head”
  1. fix suggested branch creation command when detaching headNicolas Pitre, Jan 26, 2007

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.