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

Re: ephemeral-branches instead of detached-head?

From
David Jeske <davidj@gmail.com>
Date
Aug 12, 2013, 19:05 UTC
Message-ID
<CA+CP9O6LG-dfeEKOCs48Qv9kSS4NqW1bKY8HrLeJmx2drqqSdg@mail.gmail.com>
In-Reply-To
<CACsJy8A-aSjNdSkiBUBSH43G_FBMnShfpkcwQqM9-6d41rfCUA@mail.gmail.com>
On Mon, Aug 12, 2013 at 6:23 AM, Duy Nguyen <pclouds@gmail.com> wrote:
> That would annoy me as I often work on top of detached HEAD on purpose
> and only create a branch when I want to save something. If the warning
> is to be moved, it should warn at the next checkout.
Yes, you're absolutely right ...

My point about the current checkout warning is that it's crying wolf, and nullifying the value of the warning. Most of the time I checkout a ref, I'm not doing anything dangerous because I'm not going to check anything in. The warning would be more effective if it warns in as narrow a situation as possible. You're correct that the clobber is even more narrow than the checkin.

The warning on clobber would be similar to (but shorter than) the one which could be removed from checkout..

Clobbered detached HEAD 'cce40d6'!
   git log cce40d6 ^master      # log detached changes vs master
   git branch <name> cc340d6    # name the changes with a branch

Personally, I'd prefer for explicit action to discard a detached head. It's true that this is an explicit step, but for me it generally takes a heck of alot less time to explicitly discard than it did to checkout the detached head, make changes (or apply a patch), and then decide to throw them away.

My "ephemeral branch" idea was a way to make this explicit discard as passive and lazy as possible. Basically, never stop you from doing your work, assume you know what you are doing. If the user names-the-branch it disappears. If the user merges or rebases the detached head, it disappears. The only time the "ephemeral branch" would survive is if the user really clobbered a detached head and then didn't do anything about it. Even if they missed the warning (in the middle of a script or automated process), eventually they would see the ephemeral branch lying around.

Clobbering a detached head with "ephemeral branches" could show no warning at all, or a warning like:

Clobbered detached HEAD.
   git log cce40d6 ^master           # log detached changes vs master
   git branch -D tmp/cce40d6         # Discard these changes
   git branch tmp/cce40d6 <newname>  # name this branch
Previous: David JeskeNext: Junio C Hamano
Message 10 of 24 in “ephemeral-branches instead of detached-head?”
  1. David JeskeAug 12, 2013
  2. Jonathan NiederAug 12, 2013
  3. Junio C HamanoAug 12, 2013
  4. David JeskeAug 12, 2013
  5. David JeskeAug 12, 2013
  6. Duy NguyenAug 12, 2013
  7. Andreas SchwabAug 12, 2013
  8. Junio C HamanoAug 12, 2013
  9. David JeskeAug 12, 2013
  10. David JeskeAug 12, 2013
  11. Junio C HamanoAug 12, 2013
  12. Duy NguyenAug 13, 2013
  13. Junio C HamanoAug 13, 2013
  14. Sitaram ChamartyAug 14, 2013
  15. Junio C HamanoAug 14, 2013
  16. Sitaram ChamartyAug 14, 2013
  17. Jeff KingAug 14, 2013
  18. Andres PereraAug 14, 2013
  19. Sitaram ChamartyAug 14, 2013
  20. Andres PereraAug 14, 2013
  21. Duy NguyenAug 13, 2013
  22. Fwd: ephemeral-branches instead of detached-head?David Jeske, Aug 13, 2013
  23. Junio C HamanoAug 13, 2013
  24. Junio C HamanoAug 13, 2013

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.