4

I made a mistake when I checked out a new branch with git. git version 1.7.1

I ran git branch -b --track origin/develop and I got a branch named --track. How can I delete it?

What I have done:

$ git branch
--track
* develop
master

$ git branch -d --track
$ git branch -d "--track"
$ git branch -D --track
$ git branch -D "--track"
$ git branch -D '--track'
$ git branch
--track
* develop
master
BigKuCha
  • 59
  • 5

3 Answers3

4

Rather than trying to figure out (if there is) a way to get the git tools to do it, you can simply

rm .git/refs/heads/--track
hobbs
  • 223,387
  • 19
  • 210
  • 288
4

The method in hobbs' answer will likely work. If that fails, you can use git update-ref to delete the branch name in a way that will also not start with -:

git update-ref -d refs/heads/--track

This should work even if the branch has gotten packed.

torek
  • 448,244
  • 59
  • 642
  • 775
0

Try

git branch -D -- --track

-- separates options from arguments.

phd
  • 82,685
  • 13
  • 120
  • 165