From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Myles Fong <i@myles.hk>
Cc: git <git@vger.kernel.org>
Subject: Re: Possible bug report: git checkout tag problem
Date: Mon, 8 Jan 2018 14:51:51 +0100 (STD) [thread overview]
Message-ID: <nycvar.QRO.7.76.6.1801081447350.31@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz> (raw)
In-Reply-To: <160d3e3f291.df909f06277296.7997490218741761365@myles.hk>
Hi Myles,
On Mon, 8 Jan 2018, Myles Fong wrote:
> Brief description:
> When two tags are pointing to the same commit, e.g. tagA and tagB, if I
> do `git checkout tagA` then `git checkout tagB`, and then `git status`,
> it shows `HEAD detached at tagA`
>
> Expected behaviour:
> I'm expecting it to show `HEAD detached at tagB`, though I understand
> this makes no difference for the repo code, but still a bit confusing
> for me.
The problem here is that Git understands something different from what you
intended: if you say `git checkout <commit-ish>`, Git is mostly interested
in the revision, i.e. the commit. Only if that parameter refers to a local
branch name (which is the only type of ref Git expects to advance via the
worktree) does it switch to a named branch. Otherwise it switches to what
I like to call "unnamed branch" (and which for historical reasons is
called "detached HEAD" by Git, something that is unlikely to be understood
without explicit explanation).
Now, as a convenience, Git tries to name the revision when it is on such
an unnamed branch. If a tag points to it, it uses the name of that tag to
describe it. If *multiple* tags point to it, it uses the newest one.
That's why you see what you see. It is intended behavior...
Ciao,
Johannes
prev parent reply other threads:[~2018-01-08 13:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-08 3:50 Possible bug report: git checkout tag problem Myles Fong
2018-01-08 13:51 ` Johannes Schindelin [this message]
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=nycvar.QRO.7.76.6.1801081447350.31@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=i@myles.hk \
/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).