Reputation: 2828
I'm not sure how it happened, but I somehow created a local git branch with a strange character in the branch name. When I type git branch
, one of the branches listed is myBranch<U+0094>
. I want to delete this branch, but when I go to delete the branch by copying the exact branch name, the following error happens:
$ git branch -d myBranch<U+0094>
bash: syntax error near unexpected token `newline'
I am using git bash for Windows. Any help would be appreciated. Thanks in advance!
Upvotes: 1
Views: 918
Reputation: 13616
Go to .git/refs/heads/
and delete it there using rm
. (Pro tip: use tab completion, so that your shell escapes the file name for you.)
Upvotes: 3
Reputation: 13466
Way 1:
Try using:
$ git branch -d -- myBranch<U+0094>
--
is here to inform getopt to stop parsing options.
Way 2:
PowerShell
then the escape character is the " ` " (backward apostrophe/grave or backtick).cmd.exe
then the escape character is " ^ " (carat)bash
then the escape character is " \ " (backslash)Use those escaping characters to escape special characters.
$ git branch -d myBranch\<U\+0094\>
Upvotes: 2