threads / discuss / 31076

Cannot delete weirdly named branch

Subject: Cannot delete weirdly named branch

## tl;dr

4 messages between Jul 23, 2012 and Jul 30, 2012.

replies: 3people: 3as markdown or json

abhisekpan@gmail.com· Jul 23, 2012, 18:32 UTC · lore
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· Jul 23, 2012, 18:42 UTC · re: abhisekpan@gmail.com · lore

Re: Cannot delete weirdly named branch

"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· Jul 30, 2012, 17:22 UTC · re: Junio C Hamano · lore

Re: Cannot delete weirdly named branch

On 07/23/2012 08:42 PM, Junio C Hamano wrote:
Show 10 quoted lines
> "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· Jul 30, 2012, 17:55 UTC · re: Michael Haggerty · lore

Re: Cannot delete weirdly named branch

Michael Haggerty <mhagger@alum.mit.edu> writes:
Show 14 quoted lines
> 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".

← back to recent threads