From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 54BF91FADF for ; Mon, 8 Jan 2018 13:51:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756407AbeAHNv5 (ORCPT ); Mon, 8 Jan 2018 08:51:57 -0500 Received: from mout.gmx.net ([212.227.15.15]:59179 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756246AbeAHNv4 (ORCPT ); Mon, 8 Jan 2018 08:51:56 -0500 Received: from [192.168.0.129] ([37.201.193.20]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M5Lqx-1eoGu73a9v-00zVtf; Mon, 08 Jan 2018 14:51:52 +0100 Date: Mon, 8 Jan 2018 14:51:51 +0100 (STD) From: Johannes Schindelin X-X-Sender: virtualbox@MININT-6BKU6QN.europe.corp.microsoft.com To: Myles Fong cc: git Subject: Re: Possible bug report: git checkout tag problem In-Reply-To: <160d3e3f291.df909f06277296.7997490218741761365@myles.hk> Message-ID: References: <160d3e3f291.df909f06277296.7997490218741761365@myles.hk> User-Agent: Alpine 2.21.1 (DEB 209 2017-03-23) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K0:VqiWB0iiKI0glEYQWq4v4xKPr+t7rkJoZ/IMIs+aOoHMscor47h jrpqhWFH3/a8RwRolAi6FCXGgRt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0Sg0I Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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 `, 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