threads / patch / 6548

patchfix suggested branch creation command when detaching head

Subject: [PATCH] fix suggested branch creation command when detaching head

## tl;dr

One message between Jan 26, 2007 and Jan 26, 2007. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Nicolas Pitre· Jan 26, 2007, 16:50 UTC · lore
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>
---
Show changes to git-checkout.sh +3 −3
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

← back to recent threads