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

Re: Instructions concerning detached head lead to lost local changes

From
Nicolas Pitre <nico@cam.org>
Date
Feb 2, 2007, 02:49 UTC
Message-ID
<Pine.LNX.4.64.0702012135550.3021@xanadu.home>
In-Reply-To
<7v1wl9mj48.fsf@assigned-by-dhcp.cox.net>
On Thu, 1 Feb 2007, Junio C Hamano wrote:
Show 6 quoted lines
> Alternatively we could add yet another suggestion that let's you
> discard the detached HEAD but still keep your local changes.
> Either --drop by Linus renamed to some sensible name, or "the
> obscure but useful trick".
> 
> I dunno.

I have a feeling that proper reflog for HEAD would make the issue so much simpler.

But in the mean time I tend to agree with Ted about the fact that simply losing the detached position is not _that_ important. If you go to HEAD^ and want to come back to master I think it should just work (with a display of what the last position was as Carl mentioned).

It might be some work to get to a given position with a detached head and this very position might be valuable information, but if you then do "checkout HEAD^" you will still be detached but your previous position is lost just like it would be if you moved to master. Yet you're not prevented from going to HEAD^ but you are prevented from going to master.

Same issue if you perform a commit on top of a detached head. Nothing prevents you from doing "checkout HEAD^" which will leave your head detached but it will also silently drop your last commit dangling.

In short I think there is no magic solution other than proper reflog for HEAD.

Nicolas
Previous: Carl WorthNext: Theodore Tso
Message 6 of 9 in “Instructions concerning detached head lead to lost local changes”
  1. Carl WorthFeb 1, 2007
  2. Linus TorvaldsFeb 1, 2007
  3. Junio C HamanoFeb 2, 2007
  4. Carl WorthFeb 2, 2007
  5. Carl WorthFeb 2, 2007
  6. Nicolas PitreFeb 2, 2007
  7. Theodore TsoFeb 2, 2007
  8. Nicolas PitreFeb 2, 2007
  9. Junio C HamanoFeb 2, 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.