4

Possible Duplicate:
Deleting a badly named git branch

I created a branch by mistake which starts with hyphen - , in starting character. For example

git checkout -b -z/username/workname  origin

if I try to delete the branch using

git branch -D -z/username/workname

git is throwing an parser error

error: unknown switch `z' usage: git
 branch [options] [-r | -a] [--merged |
 --no-merged]    or: git branch [options] [-l] [-f] <branchname> 
 [<start-point>]    or: git branch
 [options] [-r] (-d | -D) <branchname> 
 or: git branch [options] (-m | -M) [<oldbranch>] <newbranch>

How do I delete a branch?

Community
  • 1
  • 1
Ganesh
  • 71
  • 1
  • 3
  • very possible duplicate of [Deleting a badly named git branch](http://stackoverflow.com/questions/1192180/deleting-a-badly-named-git-branch) – Snowbear Mar 25 '11 at 13:48

3 Answers3

7

Use -- to separate the -args from the non-dash args. IE:

git branch -D -- -z/username/workname
Wes Hardaker
  • 21,735
  • 2
  • 38
  • 69
0

Try this:

git update-ref -d refs/heads/-z/username/workname
RDL
  • 7,865
  • 3
  • 29
  • 32
0

You can delete the branch with:

git branch -D /-z/username/workname
Tommy
  • 1,277
  • 1
  • 11
  • 22