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

Re: [PATCH] Detached HEAD (experimental)

From
Junio C Hamano <junkio@cox.net>
Date
Jan 2, 2007, 22:44 UTC
Message-ID
<7virfprquo.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<87ps9xgkjo.wl%cworth@cworth.org>
Carl Worth <cworth@cworth.org> writes:
Show 14 quoted lines
> On Mon, 01 Jan 2007 23:45:08 -0800, Junio C Hamano wrote:
>> This allows "git checkout -d v1.4.3" to detach the HEAD from any
>> branch but point directly at the named commit.
>
> Being able to perform "checkout" with a tag like this, (and no
> specific branch), is something I've been wanting git to acquire for
> some time. So, thanks for coding this up!
>
>> This is still experimental.  While I think it makes sense to
>> allow commits on top of detached HEAD, it is rather dangerous
>> unless you are careful and know what you are doing.
>
> This part I don't understand. I don't see why it's useful to introduce
> new danger to "git checkout"...

I am not saying being risky is useful. That's why I said it is experimental.

We could do two things, and I think disallowing commits is not necessarily a better option of the two. We could allow commits and prevent the user from switching out of the detached HEAD state without an explicit action instead. If we go the first route, you need to also prevent merges into the detached HEAD. If we go the latter I think you only need to add a check in "git-checkout" but there may be other cases. In either way, we need a safety valve, which the experimental code does not have.

And being able to merge into the detached HEAD turns out to be somewhat useful. I checked out the v1.4.4.3 and tried to see if a topic is applicable by merging into that detached HEAD and running testsuite. Of course, without any safety valve, I can easily lose the merge result by switching out of the detached HEAD state (say, "git checkout master"), but on the other hand, creating a new branch at that point with "git checkout -b v1.4.4.3-maint" would let me continue from that point without losing anything.

But this is only "somewhat" -- I do not have strong opinion either way, other than that we need a safety valve (which we agree).

In any case, I did this because I got tired of waiting for it to happen (I thought you wanted to hack on this over the long week^W yearend, so I deliberately stayed away from doing this) and I was bored. This will not be in 'next' in the current shape.

You've thought about the issue long enough to write your commentary and I agree to most of your points (including favoring "no commit allowed in this state" over "allow commits and merges to help advanced usage" for its simplicity), so if you code it up with a clean patch, I would not reject it on the basis of its design.

Previous: J. Bruce FieldsNext: Carl Worth
Message 9 of 68 in “Detached HEAD (experimental)”
  1. Detached HEAD (experimental)Junio C Hamano, Jan 2, 2007
  2. Edgar ToernigJan 2, 2007
  3. Carl WorthJan 2, 2007
  4. Jakub NarebskiJan 2, 2007
  5. Carl WorthJan 3, 2007
  6. J. Bruce FieldsJan 6, 2007
  7. Alan ChandlerJan 6, 2007
  8. J. Bruce FieldsJan 6, 2007
  9. Junio C HamanoJan 2, 2007
  10. Carl WorthJan 2, 2007
  11. Junio C HamanoJan 3, 2007
  12. Junio C HamanoJan 8, 2007
  13. Jeff KingJan 8, 2007
  14. Junio C HamanoJan 9, 2007
  15. Carl WorthJan 9, 2007
  16. Junio C HamanoJan 9, 2007
  17. Carl WorthJan 9, 2007
  18. Shawn O. PearceJan 9, 2007
  19. Junio C HamanoJan 9, 2007
  20. 0/6 Expose in_merge_bases() via merge-base.Junio C Hamano, Jan 9, 2007
  21. Luben TuikovJan 9, 2007
  22. Jeff KingJan 9, 2007
  23. Junio C HamanoJan 9, 2007
  24. J. Bruce FieldsJan 9, 2007
  25. Carl WorthJan 9, 2007
  26. J. Bruce FieldsJan 9, 2007
  27. Shawn O. PearceJan 9, 2007
  28. Jakub NarebskiJan 10, 2007
  29. Shawn O. PearceJan 10, 2007
  30. J. Bruce FieldsJan 10, 2007
  31. Shawn O. PearceJan 10, 2007
  32. Nicolas PitreJan 10, 2007
  33. Junio C HamanoJan 10, 2007
  34. Shawn O. PearceJan 10, 2007
  35. Nicolas PitreJan 10, 2007
  36. Shawn O. PearceJan 10, 2007
  37. Jakub NarebskiJan 10, 2007
  38. Andreas EricssonJan 10, 2007
  39. Junio C HamanoJan 10, 2007
  40. Daniel BarkalowJan 10, 2007
  41. Andreas EricssonJan 11, 2007
  42. Junio C HamanoJan 10, 2007
  43. Junio C HamanoJan 9, 2007
  44. Shawn O. PearceJan 9, 2007
  45. Linus TorvaldsJan 9, 2007
  46. Junio C HamanoJan 10, 2007
  47. Shawn O. PearceJan 10, 2007
  48. Linus TorvaldsJan 10, 2007
  49. Carl WorthJan 10, 2007
  50. Junio C HamanoJan 10, 2007
  51. Andy ParkinsJan 10, 2007
  52. Shawn O. PearceJan 10, 2007
  53. Junio C HamanoJan 10, 2007
  54. Andy ParkinsJan 10, 2007
  55. Shawn O. PearceJan 10, 2007
  56. Junio C HamanoJan 10, 2007
  57. Jeff KingJan 10, 2007
  58. Junio C HamanoJan 11, 2007
  59. J. Bruce FieldsJan 11, 2007
  60. Jeff KingJan 3, 2007
  61. Jeff KingJan 3, 2007
  62. git-branch: show detached HEADLars Hjemli, Jan 2, 2007
  63. Shawn O. PearceJan 3, 2007
  64. Junio C HamanoJan 3, 2007
  65. Lars HjemliJan 3, 2007
  66. Junio C HamanoJan 3, 2007
  67. Junio C HamanoJan 3, 2007
  68. Lars HjemliJan 3, 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.