# Ambiguous ref names

6 messages from 2009-11-20 to 2009-12-11. Participants: Jeenu V, Junio C Hamano.
Thread: https://gitlist.dev/t/21683

## Jeenu V, 2009-11-20 10:18

Subject: Ambiguous ref names
Message-ID: <5195c8760911200218v5b75d690hbaaf00b44c8df6af@mail.gmail.com>
URL: https://gitlist.dev/e/5195c8760911200218v5b75d690hbaaf00b44c8df6af%40mail.gmail.com

```
Hi,

I'm re-posting this from the git-users Google Groups:

If I've two branches a.b.c and a.b.c.d, why does 'git checkout'
complains about ambiguous ref names? For example, if I'm in a.b.c.d,

896 $ git checkout a.b.c
warning: refname 'a.b.c' is ambiguous.
Switched to branch "a.b.c"

Is this some kind of a side effect of commit abbreviation? If so is
this kind of branch naming considered unsafe? Is there a way to make
git accept ref names verbatim, even if there's potential operation
that'd fail because of ambiguity?

-- 
:J

```

## Junio C Hamano, 2009-11-20 10:26

Subject: Re: Ambiguous ref names
Message-ID: <7vzl6h3319.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vzl6h3319.fsf%40alter.siamese.dyndns.org
In-Reply-To: <5195c8760911200218v5b75d690hbaaf00b44c8df6af@mail.gmail.com>

```
Jeenu V <jeenuv@gmail.com> writes:

> If I've two branches a.b.c and a.b.c.d, why does 'git checkout'
> complains about ambiguous ref names?

Because it doesn't???

    : demo; git init
    Initialized empty Git repository in /var/tmp/gomi/twelve/.git/
    : demo/master; >f
    : demo/master; git add f
    : demo/master; git commit -a -m 'initial'
    [master (root-commit) cb1d5f2] initial
     0 files changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 f
    : demo/master; git branch a.b.c
    : demo/master; git branch a.b.c.d
    : demo/master; git checkout a.b.c
    Switched to branch 'a.b.c'

It could be that you have a tag and a branch that are both named a.b.c,
though.

```

## Jeenu V, 2009-11-20 10:48

Subject: Re: Ambiguous ref names
Message-ID: <5195c8760911200248v1f3d6b56q78987edfceae5541@mail.gmail.com>
URL: https://gitlist.dev/e/5195c8760911200248v1f3d6b56q78987edfceae5541%40mail.gmail.com
In-Reply-To: <7vzl6h3319.fsf@alter.siamese.dyndns.org>

```
On Fri, Nov 20, 2009 at 3:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
> [...]
> It could be that you have a tag and a branch that are both named a.b.c,
> though.

Hm, right. But I'm getting this from an existing local repo of mine. I
can't see any tags; 'git tag -l' is empty. Is there any more info that
I can provide?

FWIW, I'm running Git under Cygwin.
-- 
:J

```

## Junio C Hamano, 2009-11-20 10:59

Subject: Re: Ambiguous ref names
Message-ID: <7vpr7dzckl.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vpr7dzckl.fsf%40alter.siamese.dyndns.org
In-Reply-To: <5195c8760911200248v1f3d6b56q78987edfceae5541@mail.gmail.com>

```
Jeenu V <jeenuv@gmail.com> writes:

> On Fri, Nov 20, 2009 at 3:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> [...]
>> It could be that you have a tag and a branch that are both named a.b.c,
>> though.
>
> Hm, right. But I'm getting this from an existing local repo of mine. I
> can't see any tags; 'git tag -l' is empty. Is there any more info that
> I can provide?

man git-for-each-ref?

```

## Jeenu V, 2009-11-20 11:55

Subject: Re: Ambiguous ref names
Message-ID: <5195c8760911200355x1aff9781l848f974c9f09f416@mail.gmail.com>
URL: https://gitlist.dev/e/5195c8760911200355x1aff9781l848f974c9f09f416%40mail.gmail.com
In-Reply-To: <7vpr7dzckl.fsf@alter.siamese.dyndns.org>

```
On Fri, Nov 20, 2009 at 4:29 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Jeenu V <jeenuv@gmail.com> writes:
>
>> On Fri, Nov 20, 2009 at 3:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>> [...]
>>> It could be that you have a tag and a branch that are both named a.b.c,
>>> though.
>>
>> Hm, right. But I'm getting this from an existing local repo of mine. I
>> can't see any tags; 'git tag -l' is empty. Is there any more info that
>> I can provide?
>
> man git-for-each-ref?

It does list all refs that I know of, but I don't see any duplicate entries.
-- 
:J

```

## Jeenu V, 2009-12-11 08:03

Subject: Re: Ambiguous ref names
Message-ID: <5195c8760912110003u6deabf7ey44b1f2dd448ce7fe@mail.gmail.com>
URL: https://gitlist.dev/e/5195c8760912110003u6deabf7ey44b1f2dd448ce7fe%40mail.gmail.com
In-Reply-To: <5195c8760911200355x1aff9781l848f974c9f09f416@mail.gmail.com>

```
On Fri, Nov 20, 2009 at 5:25 PM, Jeenu V <jeenuv@gmail.com> wrote:
>
> On Fri, Nov 20, 2009 at 4:29 PM, Junio C Hamano <gitster@pobox.com> wrote:
> > Jeenu V <jeenuv@gmail.com> writes:
> >
> >> On Fri, Nov 20, 2009 at 3:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
> >>> [...]
> >>> It could be that you have a tag and a branch that are both named a.b.c,
> >>> though.
> >>
> >> Hm, right. But I'm getting this from an existing local repo of mine. I
> >> can't see any tags; 'git tag -l' is empty. Is there any more info that
> >> I can provide?
> >
> > man git-for-each-ref?
>
> It does list all refs that I know of, but I don't see any duplicate entries.

Ah, I think I get what happened here: I had used git update-ref, which
turned out to be used wrongly. My intention was to update a.b.c to a
new ref, but I used it 'git update-ref XXXXXX', rather than 'git
update-ref refs/heads/a.b.c XXXXXX'. The wrong usage created
.git/a.b.c and I guess this was causing the warning.

--
:J

```
