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

Seemingly inconsistent checkout behaviour

From
BKBart Kuster <bart.kuster@sidn.nl>
Date
Oct 11, 2022, 11:39 UTC
Message-ID
<DU2P194MB1584B11245DF0DE7515297B6E3239@DU2P194MB1584.EURP194.PROD.OUTLOOK.COM>
Dear People of Git,
I had some trouble getting out of a detached HEAD state using git checkout. I’ve solved it now but the behaviour of checkout when doing so leaves me a bit puzzled.
I’d expect the behaviour of the commands below to be equivalent:
   git checkout origin/main
vs
   git config checkout.defaultRemote origin
   git checkout main
But they are not; the former leaves the HEAD detached while the latter sets it to main. I failed to find an explanation in the git-checkout documentation, which seems to indicate that checkout always updates HEAD.
Could someone clarify what's going on?
A bit more elaborate transcript of what I did is below.
Thanks in advance!

Kind regards, Bart Kuster

---

# Checkout a commit to get into detached HEAD state $ git checkout aac02b81d735d5f15b3b3c61a84ccb79a8a90145 HEAD is now at aac02b8 Merge branch 'main' of https://repo into main $ git checkout origin/main HEAD is now at aac02b8 Merge branch 'main' of https://repo into main $ git status HEAD detached at aac02b8 (...) $ git config checkout.defaultRemote origin $ git checkout main On branch main (...) $ git status On branch main $

Next: Ævar Arnfjörð Bjarmason
Message 1 of 3 in “Seemingly inconsistent checkout behaviour”
  1. Bart KusterOct 11, 2022
  2. Ævar Arnfjörð BjarmasonOct 11, 2022
  3. Bart KusterOct 11, 2022

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.