Shawn J. Goff
Shawn J. Goff

Reputation: 4755

How to remove a branch named "--orphan"

So I was trying to create an orphan branch. I tried a couple of things and one of them (git checkout -b --orphan newbranch) managed to create a branch called "--orphan"; now it won't let me delete it using git branch -d --orphan. I've also tried using quotes and escape characters. Nothing seems to work. I also tried using gitg to delete and to rename the branch; this didn't work.

How can I delete this branch?

Upvotes: 7

Views: 1619

Answers (1)

Wayne Conrad
Wayne Conrad

Reputation: 107959

git branch -d -- --orphan

Everything after -- is taken as an argument and not a switch. This works in many places in git (and in many other Unix programs).

Upvotes: 11

Related Questions