git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Bart Kuster <bart.kuster@sidn.nl>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Seemingly inconsistent checkout behaviour
Date: Tue, 11 Oct 2022 11:39:07 +0000	[thread overview]
Message-ID: <DU2P194MB1584B11245DF0DE7515297B6E3239@DU2P194MB1584.EURP194.PROD.OUTLOOK.COM> (raw)

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
$

             reply	other threads:[~2022-10-11 11:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11 11:39 Bart Kuster [this message]
2022-10-11 12:14 ` Seemingly inconsistent checkout behaviour Ævar Arnfjörð Bjarmason
2022-10-11 13:03   ` Bart Kuster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DU2P194MB1584B11245DF0DE7515297B6E3239@DU2P194MB1584.EURP194.PROD.OUTLOOK.COM \
    --to=bart.kuster@sidn.nl \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).