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

[PATCH 5/5] docs/checkout: clarify what "non-branch" means

From
Jeff King <peff@peff.net>
Date
Apr 13, 2009, 11:21 UTC
Message-ID
<20090413112104.GE15982@coredump.intra.peff.net>
In-Reply-To
<20090413110947.GA15647@coredump.intra.peff.net>

In the code we literally stick "refs/heads/" on the front and see if it resolves, so that is probably the best explanation.

Signed-off-by: Jeff King <peff@peff.net>
---
I hope this helps a little bit with Mark's confusion. But while writing
it, I really think it would be a simpler rule to say "if it's in
refs/heads/, then it's a branch" (which is similar to what Mark
suggested earlier).

So "git checkout refs/heads/master" would be identical to "git checkout master". That would require a code change, though.

 Documentation/git-checkout.txt |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 4a1fb53..ad4b31e 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -114,11 +114,11 @@ the conflicted merge in the specified paths.
 	"merge" style, shows the original contents).
 
 <branch>::
-	Branch to checkout (when no paths are given); may be any object
-	ID that resolves to a commit.  Defaults to HEAD.
-+
-When this parameter names a non-branch (but still a valid commit object),
-your HEAD becomes 'detached'.
+	Branch to checkout; if it refers to a branch (i.e., a name that,
+	when prepended with "refs/heads/", is a valid ref), then that
+	branch is checked out. Otherwise, if it refers to a valid
+	commit, your HEAD becomes "detached" and you are no longer on
+	any branch (see below for details).
 +
 As a special case, the `"@\{-N\}"` syntax for the N-th last branch
 checks out the branch (instead of detaching).  You may also specify
-- 
1.6.3.rc0.148.g141203.dirty
Previous: Jeff KingNext: Junio C Hamano
Message 15 of 24 in “builtin-branch - allow deleting a fully specified branch-name”
  1. builtin-branch - allow deleting a fully specified branch-nameMark Levedahl, Apr 10, 2009
  2. Junio C HamanoApr 10, 2009
  3. Mark LevedahlApr 10, 2009
  4. Junio C HamanoApr 10, 2009
  5. Mark LevedahlApr 11, 2009
  6. Jeff KingApr 12, 2009
  7. Junio C HamanoApr 12, 2009
  8. Jeff KingApr 13, 2009
  9. Junio C HamanoApr 13, 2009
  10. Jeff KingApr 13, 2009
  11. 1/5 doc: clarify --no-track optionJeff King, Apr 13, 2009
  12. 2/5 doc: refer to tracking configuration as "upstream"Jeff King, Apr 13, 2009
  13. 3/5 doc/checkout: refer to git-branch(1) as appropriateJeff King, Apr 13, 2009
  14. 4/5 doc/checkout: split checkout and branch creation in synopsisJeff King, Apr 13, 2009
  15. 5/5 docs/checkout: clarify what "non-branch" meansJeff King, Apr 13, 2009
  16. Junio C HamanoApr 13, 2009
  17. Mark LevedahlApr 14, 2009
  18. Junio C HamanoApr 14, 2009
  19. Jakub NarebskiApr 14, 2009
  20. Jeff KingApr 15, 2009
  21. Jeff KingApr 15, 2009
  22. Jeff KingApr 13, 2009
  23. Jeff KingApr 13, 2009
  24. Sverre RabbelierApr 13, 2009

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.