How to remove a branch with a name starting with '-'

In an attempt to create a tracking branch, I managed to create a local branch named '-t'. I cannot delete a branch because the branch name is also a parameter. This is located on a Windows computer.

$ git branch -D -t
fatal: branch name required

Escaping doesn't help either

$ git branch -D \-t
fatal: branch name required

Putting the branch name in quotation marks does not help

$ git branch -D "-t"
fatal: branch name required

Using git gui to try to remove a branch gives the same error message.

I thought to just remove the '-t' from .git / refs / heads - is that enough? Or is it still not? Or is there a way to remove it from the command line?

+4
source share
1 answer

Use option --

git branch -D -- -t

As you can read here

(--) bash ,

Git -t , --.

+8

All Articles