From: Junio C Hamano Date: Thu, 12 Nov 2026 15:40:22 GMT Subject: Re: [PATCH v4] doc: checkout: rewrite detached HEAD state explanation Message-ID: In-Reply-To: Julia Evans writes: > Yeah I agree the "it's the parent of the next commit" would be > distracting unless there's a specific reason we need to include it. > > I agree "the state from which your current changes started" isn't right > but I think if we reinterpret it as "the current commit you have checked > out" (which I think has the same or a very similar meaning) then it'll > seem familiar to folks and might even help. > ... > because I couldn't think of a reason why someone would clobber an > existing branch to check out an old version of their code. When I find something interesting in a topic, which may be an old commit from the point of view of 'seen', I would detach HEAD at the tip of the branch to take a look at its contents, because what I am going to do next would very often involve modifying the working tree files to experiment. Even a topic that is documentation only, like the je/doc-detached-head topic, can have a cascading effect that ends up breaking tests, for example, and I'd be futzing with the sources and tests to figure out what the best fix would be. Even though I am not going to make any permanent commits out of these efforts, being able to make temporary commits to mark a resumable state is handy, and when my spelunking gets longer, I do make such commits. But of course, I do *not* want to contaminate the topic branch I have been looking at. The work I do, whether it is for validation or for satisfying my own curiosity, does not necessarily align with the objective the topic author had in mind when they wrote it. This is where detached HEAD is the perfect mechanism to take advantage of. You do not want to clobber the branch you are going to start your journey at, yet you want to be able to make tentative changes to experiment, and you want to be able to take snapshots. And during the journey, your HEAD points at a commit from which your current changes started and points at a commit your next commit will record as its parent. I guess it requires a developer's mindset and imagination to appreciate why detached HEAD is useful while spelunking. We often phrase the act of visiting random commits (often older ones) as "sight-seeing", but in reality, even when you are mostly looking, you do want to futz with things you see there. It is in a developer's heart ;-). Hope this clarifies.