Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a branch named "--orphan"

Tags:

git

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?

like image 571
Shawn J. Goff Avatar asked Oct 26 '10 14:10

Shawn J. Goff


People also ask

How do I delete an orphan branch?

Use git prune to remove orphaned/unused branches If you see any branches in there that you don't want, you can use the command git branch -d <branch name> . If you want to delete the branch called badbranch, use the -D switch to force the deletion if it doesn't work: git branch -d badbranch .

What is an orphan branch?

An orphan branch is a separate branch that starts with a different root commit. So the first commit in this branch will be the root of this branch without having any history. It can be accomplished by using the Git checkout command with the ––orphan option.


1 Answers

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).

like image 119
Wayne Conrad Avatar answered Sep 21 '22 00:09

Wayne Conrad