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

Re: [PATCH 3/3] prevent HEAD reflog to be interpreted as current branch reflog

From
Nicolas Pitre <nico@cam.org>
Date
Feb 2, 2007, 15:13 UTC
Message-ID
<Pine.LNX.4.64.0702020955540.3021@xanadu.home>
In-Reply-To
<200702021302.10567.andyparkins@gmail.com>
On Fri, 2 Feb 2007, Andy Parkins wrote:
> Forgetting about detached heads for the moment,

That is not the way to go about it. You cannot start forgetting about detached heads and come back to it afterwards like an afterthought.

Show 6 quoted lines
> imagine that yesterday I did 
> lots of bouncing around on branches, around 1300 (although I wouldn't 
> remember the exact time).  Oh look, it's about 1300 now.  What then is
> HEAD@{yesterday} going to tell me?  What will it tell me one minute from now?  
> It would be the most confusing operation in the world; I'd have to remember 
> which branch I had checked out and what time I checked it out.

The exact same argument could be said if you did 1300 operations on a single branch, say master. What would master@{yesterday} tell you? What will it tell you one minute from now? Now suppose that you have only one branch and therefore HEAD reflog would be a duplicate of master reflog.

Answer: it would carry the same kind of confusion as your example above.
> I really don't want to be able to answer the question what branch did I have 
> checked out 15 minutes ago.  I do want to ask where was my current branch 15 
> minutes ago.

Then simply use @{15 minutes ago}. You'll even save yourself some typing! It is not like if you have to type HEAD for most operations anyway since HEAD is the likely default in most cases. So you may even forget that the HEAD entity exists and be just fine.

But HEAD is still a moving pointer and we might want to know that it switched from one branch to another at some point. And the only way for that to be sensible is by having a separate reflog for HEAD that is the exact log of every operations you perform regardless of the actual branch you might be on.

Show 9 quoted lines
> Then of course, it's perfectly reasonable to treat the detached HEAD as 
> meaning that the symref HEAD was pointing at a kind of virtual branch - this 
> is a branch that isn't in the refs directory but is reflogged.  Other than 
> that it's no different from any other branch.
> 
> Any notation would do I think, @{} is as good as any other.  In fact, if we 
> used the name "unnamed branch" instead of "detached head", the notation @{} 
> is perfect.  (Actually I think unnamed branch is a much better term than 
> detached HEAD, because HEAD is never detached - it must point at something)

HEAD _does_ get detached. It becomes loose in the air. It doesn't drag any branch pointer with it. And everything you do on top of a detached HEAD will be forgotten as soon as you leave it (and the eventual reflog for HEAD expires) if you don't attach it somehow with a tag or a new branch. There is no notion of a virtual branch at all, not technically, not conceptually either.

Nicolas
Previous: Nicolas PitreNext: Andy Parkins
Message 17 of 35 in “prevent HEAD reflog to be interpreted as current branch reflog”
  1. 3/3 prevent HEAD reflog to be interpreted as current branch reflogNicolas Pitre, Feb 1, 2007
  2. Shawn O. PearceFeb 1, 2007
  3. Junio C HamanoFeb 1, 2007
  4. Simon 'corecode' SchubertFeb 1, 2007
  5. Nicolas PitreFeb 1, 2007
  6. Matthias LederhoferFeb 1, 2007
  7. 4/3 provide a nice @{...} syntax to always mean the current branch reflogNicolas Pitre, Feb 1, 2007
  8. 5/3 , was Re: [PATCH 4/3] provide a nice @{...} syntax to always mean the current branch reflogJohannes Schindelin, Feb 1, 2007
  9. 6/3 , was Re: [PATCH 5/3], was Re: [PATCH 4/3] provide a nice @{...} syntax to always mean the current branch reflogJohannes Schindelin, Feb 1, 2007
  10. Junio C HamanoFeb 2, 2007
  11. Nicolas PitreFeb 1, 2007
  12. Jakub NarebskiFeb 2, 2007
  13. Johannes SchindelinFeb 2, 2007
  14. Lars HjemliFeb 2, 2007
  15. Andy ParkinsFeb 2, 2007
  16. Nicolas PitreFeb 2, 2007
  17. Nicolas PitreFeb 2, 2007
  18. Andy ParkinsFeb 2, 2007
  19. Simon 'corecode' SchubertFeb 2, 2007
  20. Nicolas PitreFeb 2, 2007
  21. Mark WoodingFeb 3, 2007
  22. Andy ParkinsFeb 3, 2007
  23. Jakub NarebskiFeb 2, 2007
  24. Simon 'corecode' SchubertFeb 2, 2007
  25. Simon 'corecode' SchubertFeb 2, 2007
  26. Nicolas PitreFeb 2, 2007
  27. Lars HjemliFeb 2, 2007
  28. Johannes SchindelinFeb 5, 2007
  29. Shawn O. PearceFeb 5, 2007
  30. Johannes SchindelinFeb 5, 2007
  31. Lars HjemliFeb 5, 2007
  32. Andy ParkinsFeb 2, 2007
  33. Rogan DawesFeb 2, 2007
  34. Andy ParkinsFeb 2, 2007
  35. Junio C HamanoFeb 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.