'Git: cannot delete local branch

I was trying to track a remote branch with $ git checkout -b --track global/master, and git created a branch named "--track". Now, when I run $ git branch -D --track it won't delete the branch. I believe Git is parsing the last argument, --track, as a git-branch subcommand flag, not a branch name.

I attempted to quote the branch name with $ git branch -D '--track' and escape the leading hyphen with $ git branch -D \--track.

How can I delete the "--track" branch?



Solution 1:[1]

As Uli Köhler already said:

git branch -D -- --track

The command will work to delete your branch.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community