tags:

views:

76

answers:

1

I mistyped a git command which resulted in the creation of a local branch called, '--track'.

I've tried the following:

git branch -m --track delme
(this renames the current branch to delme, not the branch called --track)

git checkout --track
> fatal: --track needs a branch name

git branch -d --track
(does nothing, reports nothing)

git branch -D --track
(also does nothing)

git branch -d "--track"
(also does nothing

How can I delete this branch?

+10  A: 
git branch -d -- --track

In general, -- tells git to treat all subsequent command-line arguments as non-options.

EDIT: See the comments for clarification regarding how git uses --.

Marcelo Cantos
Perfect :-) Thanks very much.
Rich
Actually, `--` tells pretty much *any* Unix command to treat all subsequent command-line arguments as non-options.
Jörg W Mittag
But many git commands use `--` as a separator between revision(s) and pathspec arguments (neither of which are options)... but not in the case of `git branch`.
Jakub Narębski