Re: determine name of tag used for checkout when multiple tags exist?
- From
John Keeping <john@keeping.me.uk>
- Date
- Sep 4, 2015, 11:19 UTC
- Message-ID
- <20150904111915.GB27660@serenity.lan>
- In-Reply-To
- <CAL3By-8cgAz1Jau3NO0kkHAVwvy3hPMMUn=xwUtY78TE5WE9vw@mail.gmail.com>
[It looks like your reply didn't get through to the mailing list, presumably because it contained a text/html part.]
On Fri, Sep 04, 2015 at 04:22:04AM -0600, Jesse Hopkins wrote:
Show 16 quoted lines
> On Sep 4, 2015 1:54 AM, "John Keeping" <john@keeping.me.uk> wrote:
> > When I checkout a tag, "git reflog -1" gives something like:
> >
> > 989d251 HEAD@{0}: checkout: moving from master to v0.9.2
> >
> > Since whitespace isn't permitted in tag names you can do something like:
> >
> > tag=$(git reflog -1)
> > tag=${tag##* }
> > git cat-file tag "$tag" >/dev/null 2>&1 || echo "not a tag!"
>
> Thanks John that seems promising. One limitation it seems is that the
> reflog doesn't contain the tag name on a freshly cloned repo which used the
> tag as the -b option. However it seems I can recover the tag name from
> the reflog so long as I clone against something other than the tag, then
> checkout the tag.I think it would be a reasonable enhancement to include the branch name in the reflog message if "-b" is given to "git clone", but I'm not aware of any (formal) policy on the format of reflog messages so relying on any particular message may not be 100% reliable across Git upgrades.