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. Commented Mar 1, 2014 at 0:50
  • 4
    Have you tried $ git branch -D -- --track ? Commented 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.

Sign up to request clarification or add additional context in comments.

1 Comment

Didn't work for me git branch -D -- --track error: branch '--track' not found.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.