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?
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 .
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With