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

Re: user manual question

From
Sitaram Chamarty <sitaramc@gmail.com>
Date
Dec 29, 2008, 17:27 UTC
Message-ID
<slrngli24v.8cd.sitaramc@sitaramc.homelinux.net>
In-Reply-To
<gjauel$94s$4@ger.gmane.org>
On 2008-12-29, Zorba <cr@altmore.co.uk> wrote:
> so a detached HEAD is just a HEAD that is not sitting on a tip ?
yes...
Show 5 quoted lines
> i.e. if I do $ git reset --hard HEAD^
>
> ...pointing HEAD to the previous committ
>
> this is a detached HEAD

...but no. This is because git reset moves the tip of the branch also (in this case, backward by one commit from the previous). In effect, you're saying "discard my latest commit and roll back by one".

"git checkout HEAD^" would get you a detached head though. In this case you're saying "let the branch be where it is, but let HEAD move up one level". So HEAD is now NOT at a tip, and it'a a detached head.

It's instructive to run "gitk --all" when you're doing these experiments sometimes.

> (I thought a detached HEAD was maybe a head somewhere on another branch not 
> "reachable", i.e. a sibling, not a ancestor...
> or something like that)
no no that's just another branch that's all.

All this is pretty confusing in the beginning, but if you don't lose your head, it'll all become clear eventually.

[What's that they say? Oh yeah "thank you ladies and gentlemen I'll be here all night"!]

Previous: Markus HeidelbergNext: Daniel Barkalow
Message 11 of 12 in “user manual question”
  1. ZorbaDec 28, 2008
  2. Sitaram ChamartyDec 28, 2008
  3. Dilip MDec 28, 2008
  4. ZorbaDec 29, 2008
  5. ZorbaDec 28, 2008
  6. Sitaram ChamartyDec 29, 2008
  7. Dilip MDec 29, 2008
  8. ZorbaDec 29, 2008
  9. Björn SteinbrinkDec 29, 2008
  10. Markus HeidelbergDec 29, 2008
  11. Sitaram ChamartyDec 29, 2008
  12. Daniel BarkalowDec 29, 2008

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.