13

I was trying to track a remote branch with $ git checkout -b --track global/master, and git created a branch named "--track". Now, when I run $ git branch -D --track it won't delete the branch. I believe Git is parsing the last argument, --track, as a git-branch subcommand flag, not a branch name.

I attempted to quote the branch name with $ git branch -D '--track' and escape the leading hyphen with $ git branch -D \--track.

How can I delete the "--track" branch?

2
  • I cannot create branch with this name, git complains.
    – Rafa Paez
    Mar 1, 2014 at 0:50
  • 4
    Have you tried $ git branch -D -- --track ? Mar 1, 2014 at 0:51

1 Answer 1

6

As Uli Köhler already said:

git branch -D -- --track

The command will work to delete your branch.

1
  • 4
    Didn't work for me git branch -D -- --track error: branch '--track' not found. Nov 29, 2017 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.