theCuriousGee
theCuriousGee

Reputation: 77

Can't delete local git branch

So, I was deleting a local branch with the command git branch -D and after deleting the branch, a new branch, named '-D' showed up in my local repo. So now when I run 'git branch' there is a branch called '-D'.

Unfortunately, when I try to delete this branch, using 'git branch -D -D', I get a 'fatal: branch name required' error.

Any ideas how to get rid of this branch?

Upvotes: 3

Views: 289

Answers (1)

larsks
larsks

Reputation: 311258

You can try:

git branch -D -- -D

Where -- is a fairly common syntax for "stop interpreting - as introducing an option after this point". This seems to work in my test:

$ git branch
  -D
  foo
* master
$ git branch -D -- -D
Deleted branch -D (was 460317a).

If that doesn't work, you could try to delete .git/refs/heads/-D if it exists.

Upvotes: 3

Related Questions