From: Julia Evans Date: Mon, 19 Oct 2026 14:05:58 GMT Subject: Re: [PATCH] doc: checkout: rewrite detached HEAD state explanation Message-ID: <9c15d34e-406d-4702-b606-da102a340e71@app.fastmail.com> In-Reply-To: On Wed, Oct 7, 2026, at 12:43 PM, Junio C Hamano wrote: > "Julia Evans via GitGitGadget" writes: > >> diff --git a/Documentation/detached-head.adoc b/Documentation/detached-head.adoc >> new file mode 100644 >> index 0000000000..1e00712124 >> --- /dev/null >> +++ b/Documentation/detached-head.adoc >> @@ -0,0 +1,43 @@ >> +`HEAD` is where Git stores your current branch. `HEAD` can either be: >> + >> +1. A branch, which is your current branch. >> +2. A commit ID, when you don't have a current branch. >> + This is called "detached HEAD state". > > HEAD is branch which can either be a branch or something else? > > HEAD records the state from which your current changes started. > This can be a branch (the "current branch"), or it may not be > associated with any concrete branch (in which case HEAD is > "detached"). You asked for a more detailed explanation for why I don't think this is clearer, so here's my best attempt. It's important to use the same words that users might themselves use to describe a concept, for example, "means", "is", "points at", "is a reference to", etc. In March 2024 I asked experienced Git users to explain their impressions of what HEAD means, and I got a lot of really great replies. I've included a bunch of them at the end of this email. I think it's a really great example of how there are a lot of "technically wrong but useful" ideas about how things in Git work. When I think about how to explain HEAD, it's in the context of that research I did around March 2024. Your suggestion ("HEAD records the state from which your current changes started." uses pretty different language ("records") from the language users are using in the quotes below. I think it would be great if we could make a correct statement that builds on the ideas that users already have about HEAD, using the kind of language that they themselves would use to describe the ideas. Let me know if this is a helpful way for you to bring some user perspectives into the conversation. Like I said earlier I don't really think it's possible to discuss how to explain HEAD in a vacuum so maybe these quotes will help! Also if you could give me any ideas for how to reply in a "shorter" way than "I don't think this is clearer" let me know, I can't bring you quotes from user research to justify every single wording choice :) - "HEAD is a mysterious thing I never need to know about unless something has g-one wrong, eg. merge conflicts." -"the HEAD Commit in my Clone of our Repo is the Commit at the top of: git log" - "Other than seeing "detached head" sometimes and panicking, I don't really know what Head is. And I used git quite a bit over the years 😅" - "HEAD points at the latest commit of the branch you're viewing. Except when it doesn’t. There's attached and detached head situations and that's where it gets somewhat confusing." - "It is a… thing… which “points at”… the newest (?) commit that “”I”” am ¿on?" - "it's a pointer to the latest commit on the currently checked out branch" - "HEAD means (a pointer to) the (commit hash of the) checked-out branch" - "HEAD is the reference to the current commit that's checked out." - "The commit which will be the parent of the next commit you create, at least using "git commit" command." - "unless I am taking special pains to deliberately edit history, HEAD will (1) become the first parent of whichever commit I write next AND (2) names the branch where that commit will be appended". - "it's where you "currently are" on a branch (or maybe in the whole repo? not sure on head vs HEAD)" - "the most recent commit on the branch you're working on" - "Insertion point for new commits." - "HEAD is a "commit-like"? that refers to the commit? that was used? to populate the working directory?" - "a file in .git that points to either a commit or a ref; git uses this as the "current" commit for things like git status" - "HEAD is a symbolic reference to another reference ... I don't have a mental model for what happens if HEAD points at a tag ref" - "my impression is that it's the commit I'm currently looking at. It's attached if that commit is the tip of a branch (means I can make new commits), and it's detached when that is not the case." - "it's a file that contains the currently checked-out commit id or branch name?" - "Sometimes I think I kinda understand. Then I remember the existence of the phrase “detached HEAD”." - "HEAD is what is going to be the parent of your next commit" - "HEAD points at the latest commit in the branch you're currently in. So if you're in main, it's the latest commit there. If you're in dev, it's the latest commit in that branch. ... But if you're in a branch and not on the latest commit, HEAD still points at the latest commit." - "HEAD is shorthand for "most recent commit on current branch"." - "it means "the commit I have checked out at this very moment"." - "I am quite unconfident as I only ever see it mentioned when running 'git reset'. From that context, something like "the most recent 'saved' state of the repo before you made any 'unsaved' modifications"" - "A pointer to the *latest* commit (not necessarily "current" commit) in whatever I'm working on. ... the latest commit" is whatever is conceptually "at the end" of the branch's timeline." - "HEAD is used as a pointer to the current commit, while it is (usually) pointer to the current branch, which head (lowercase) points to the current commit - one layer of indirection." - "I think of it as pointing to the next place where a commit would appear if I made one" - "HEAD is a reference to a commit, either directly or indirectly. A direct commit is just in detached state, where HEAD is looking at the commit itself. An indirect reference would be the case you’ve shown above, where HEAD is a reference to a reference." - "Its like... the thing at the end of the branch, right? Like... the current commit." - "I think in practice it is the last ref checked out. Sometimes it is the SHA of the revision (detached head), sometimes it is a ref (branch or tag)." - "HEAD means the head of a specific branch, which seems to be the default branch in github?" - "the git command that involves HEAD which I use most often is `git push origin HEAD` ... I'd definitely struggle to articulate why this works the way that it does"