# Cannot delete weirdly named branch

4 messages from 2012-07-23 to 2012-07-30. Participants: abhisekpan@gmail.com, Junio C Hamano, Michael Haggerty.
Thread: https://gitlist.dev/t/31076

## abhisekpan@gmail.com, 2012-07-23 18:32

Subject: Cannot delete weirdly named branch
Message-ID: <CAGhmpEGEZchXc4DqZ21BAKxf6_mHRp=TOUH8s=GG0vPscz1kfg@mail.gmail.com>
URL: https://gitlist.dev/e/CAGhmpEGEZchXc4DqZ21BAKxf6_mHRp%3DTOUH8s%3DGG0vPscz1kfg%40mail.gmail.com
In-Reply-To: <CAGhmpEFg2ZcwqO=wDNPLfPCnrobq4oOcwvFCm27vrEuiES2XbQ@mail.gmail.com>

```
Hi,

I am a new user to git and I found an interesting behavior in git. I
am not sure if this is a bug, but I thought I would report this
anyway!

So I can create a local branch called "--tracking" like this:
git checkout -b --tracking origin/somebranch
I messed up the syntax while trying to create a tracking branch, but
this resulted in a local branch called "--tracking".

Now I cannot delete this branch. Running:
git branch -d --tracking
gives an error: unknown option `tracking'

Using quotes around the name does not help. Is there another command I
can use to delete this branch?

Thank you!
--
Abhisek
Live Long and Prosper

```

## Junio C Hamano, 2012-07-23 18:42

Subject: Re: Cannot delete weirdly named branch
Message-ID: <7vsjcil3o5.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vsjcil3o5.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CAGhmpEGEZchXc4DqZ21BAKxf6_mHRp=TOUH8s=GG0vPscz1kfg@mail.gmail.com>

```
"abhisekpan@gmail.com" <abhisekpan@gmail.com> writes:

> Now I cannot delete this branch. Running:
> git branch -d --tracking
> gives an error: unknown option `tracking'

I do not think this is supposed to work, but it does by accident.

    $ git branch -d -- --tracking
    Deleted branch --tracking (was 8670e20).

A more recent git would not let you create such a branch to begin
with. Perhaps time to upgrade?

```

## Michael Haggerty, 2012-07-30 17:22

Subject: Re: Cannot delete weirdly named branch
Message-ID: <5016C2C9.5050904@alum.mit.edu>
URL: https://gitlist.dev/e/5016C2C9.5050904%40alum.mit.edu
In-Reply-To: <7vsjcil3o5.fsf@alter.siamese.dyndns.org>

```
On 07/23/2012 08:42 PM, Junio C Hamano wrote:
> "abhisekpan@gmail.com" <abhisekpan@gmail.com> writes:
>
>> Now I cannot delete this branch. Running:
>> git branch -d --tracking
>> gives an error: unknown option `tracking'
>
> I do not think this is supposed to work, but it does by accident.
>
>      $ git branch -d -- --tracking
>      Deleted branch --tracking (was 8670e20).

The plumbing command "git update-ref -d refs/heads/--tracking" can also 
be used to delete such a branch.

Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/

```

## Junio C Hamano, 2012-07-30 17:55

Subject: Re: Cannot delete weirdly named branch
Message-ID: <7vk3xlqgl3.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vk3xlqgl3.fsf%40alter.siamese.dyndns.org
In-Reply-To: <5016C2C9.5050904@alum.mit.edu>

```
Michael Haggerty <mhagger@alum.mit.edu> writes:

> On 07/23/2012 08:42 PM, Junio C Hamano wrote:
>> "abhisekpan@gmail.com" <abhisekpan@gmail.com> writes:
>>
>>> Now I cannot delete this branch. Running:
>>> git branch -d --tracking
>>> gives an error: unknown option `tracking'
>>
>> I do not think this is supposed to work, but it does by accident.
>>
>>      $ git branch -d -- --tracking
>>      Deleted branch --tracking (was 8670e20).
>
> The plumbing command "git update-ref -d refs/heads/--tracking" can
> also be used to delete such a branch.

Note that once you started using the plumbing you are assumed to
know what you are doing.  "update-ref -d" does not offer the "you
will be losing these commits" safety, and it will not remove
configuration items for "branch.--tracking.*" keys.  You would want
to remove them yourself if you want to emulate "git branch -d".

```
