Not a valid git branch name

Viewed 26142

I am trying to create a new branch under feature tag of my repo, I am using following to do this:

 git branch "feature/BA-302-[AU]Intl-BCard"                            

However I am getting:

fatal: 'feature/BA-302-[AU]Intl-BCard' is not a valid branch name.

Not sure, what I am missing

Also to clarify, I have already tried to:

git checkout -b feature/BA-302-[AU]Intl-BCard

With the following result:

zsh: no matches found: feature/BA-302-[AU]Intl-BCard

2 Answers

[ is not allowed in a branch name. See man git-check-ref-format or here for more details.

In zsh, [...] defines a character class the shell tries to match. If there's no match, you get the error zsh: no matches found. Using quotes prevents the matching. In bash, similar behaviour can be turned on by running shopt -s failglob.

In my case it was a space. Branch name can't contain whitespace character.

Related