Rylander
Rylander

Reputation: 20159

Git branch named "--help"

I was running with a detached head and went to create a branch to hold my work. I ran the command git checkout -b --help to double check the options for creating a branch.

Now I have a branched named "--help"

How do I do anything with this branch? Trying to do anything with it just gives me help messages.

Details: git version 1.7.3.5

Upvotes: 1

Views: 121

Answers (2)

Nils Werner
Nils Werner

Reputation: 36765

Command line tools that accept options (-h, --help etc.) have a special argument that separates non-options from options: --

So try this:

git branch -d -- --help

This effectively makes --help a non-option, meaning you can use it as the branch name in your command line parameters.

By the way, this also goes for other commands:

cp -- README -r

will copy README to a new file -r.

Upvotes: 6

Eric Hein
Eric Hein

Reputation: 40

Have you tried putting the name of the branch in quotes on the command line? Like

git branch -d "--help"

Upvotes: -1

Related Questions