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

Re: More Beginning Git Questions

From
KKKonstantin Khomoutov <flatworm@users.sourceforge.net>
Date
Sep 26, 2011, 00:34 UTC
Message-ID
<20110926003447.GG10955@localhost.localdomain>
In-Reply-To
<1ttmqsxtaj98i$.hv6s5shjeugr.dlg@40tude.net>
On Sun, Sep 25, 2011 at 10:07:24PM +0100, tactical wrote:
[...]
Show 15 quoted lines
> > I think you can use detached HEAD for that, at least when working on
> > one issue at a time (you have to name branch when switching to some
> > other work).
> 
> But in Mercurial I can switch between anonymous branches as much as I like
> without anything ever being deleted.
> 
> >> From what I read, detached heads are subject to garbage collection.
> >  
> > No, HEAD is protected against garbage collecting.  To be sure you
> > should name a branch when switching branches, though reflog would
> > protect you for 30 days (by default) even if you don't do that.
> 
> So Git doesn't really support anonymous branching as part of a normal
> workflow.

I perceive a certain logical fallacy here: you cannot switch between anything anonymous because to switch, you should somehow identify something to switch to--a name in whatever sense we put into this word. As I understand, by switching between branches in Mercurial you mean switching between directories with clones; if so, you had had to name those directories when they were created.

As to branches, they do have names in Git but they are very loosely coupled with their names: tag a tip of some branch (to still have a handle on that tip commit) then delete that branch--there will be no traces of that branch's name left, the branch's name is not encoded in its history in any way. The branch names is just a way to not mess with SHA-1 names of commits (and to have references to those commits to keep them out of consideration for garbage collection). Hence the idea to demand support for anonymous branches in Git's model is just unfounded.

Previous: tacticalNext: tactical
Message 16 of 24 in “More Beginning Git Questions”
  1. Jon ForrestSep 23, 2011
  2. Matthieu MoySep 23, 2011
  3. Jakub NarebskiSep 23, 2011
  4. Jon ForrestSep 23, 2011
  5. Mihamina RakotomandimbySep 23, 2011
  6. Jakub NarebskiSep 23, 2011
  7. tacticalSep 24, 2011
  8. Frans KlaverSep 24, 2011
  9. tacticalSep 24, 2011
  10. Seth RobertsonSep 24, 2011
  11. tacticalSep 25, 2011
  12. Jakub NarebskiSep 25, 2011
  13. tacticalSep 25, 2011
  14. Jakub NarebskiSep 25, 2011
  15. tacticalSep 25, 2011
  16. Konstantin KhomoutovSep 26, 2011
  17. tacticalSep 26, 2011
  18. Andrew ArdillSep 26, 2011
  19. tacticalSep 26, 2011
  20. Jakub NarebskiSep 26, 2011
  21. Jakub NarebskiSep 24, 2011
  22. tacticalSep 24, 2011
  23. Jakub NarebskiSep 25, 2011
  24. Junio C HamanoSep 23, 2011

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.