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, 07:14 UTC
Message-ID
<Pine.LNX.4.64.0702020206480.3021@xanadu.home>
In-Reply-To
<20070202065949.GI18880@thunk.org>
On Fri, 2 Feb 2007, Theodore Tso wrote:
Show 26 quoted lines
> On Thu, Feb 01, 2007 at 09:49:27PM -0500, Nicolas Pitre wrote:
> > 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.
> 
> Exactly.  With Junio's reasoning, then why aren't we forcing -f in this sequence:
> 
> git checkout HEAD^
> git checkout HEAD^^
> git checkout HEAD^^^
> git checkout -f master
> 
> The first three are just as likely to "lose" information as the last.
> Personally, I don't think any of this is "losing" information, any
> more than I "lose" information in the following sequence of commands:
> 
> cd /usr/src/linux/drivers/net
> cd /usr/src/linux/drivers/char
> cd /usr/src/linux/fs/ext3
> cd /home/tytso
> 
> The current working directory is just like the detached HEAD.  If I'm
> moving it around, there is no loss of data.  cd != rm.

It's just that moving around amongst thousands of commits to pin point a particular commit might require some digging work. This is why there might be some value in a particular position and why there is an attempt at protecting that "work".

But since moving to another position while still remaining detached from any branch has the same potential for losing the important position and so without any kind of protection then it makes no sense to have such a protection when moving back to a branch.

Nicolas
Previous: Theodore TsoNext: Junio C Hamano
Message 8 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.