1

I like to use branch like [#3]feature: filter [#issue num]type: title

But terminer shows me "zsh: no matches found: [#3]feature:filter"

Can't i use "[ ]" on branch names?

phd
  • 82,685
  • 13
  • 120
  • 165
hyojin
  • 21
  • 5
  • 1
    As [ElpieKay answered](https://stackoverflow.com/a/68901143/1256452), no, these aren't valid—but the error you're getting happens before zsh even asks Git to do anything. "Shells", including zsh, bash, and others, are themselves programming languages. Commands you type in at the command line are sometimes requests that the shell itself do something, instead of or before running some *other* command. For instance, `for i in a b c; do echo $i; done` is a mini shell script that runs `echo a`, then `echo b`, then `echo c`, producing three lines of output in the end. – torek Aug 24 '21 at 08:09
  • 1
    In your case, you're using *shell metacharacters:* square brackets are part of [glob matching](https://en.wikipedia.org/wiki/Glob_(programming)), which directs your shell to look for certain files in the current or otherwise-specified directory. Your particular match request fails to find any matching files. In zsh, this produces an error message, which is the one you're seeing. – torek Aug 24 '21 at 08:11

1 Answers1

6

Git has a command git check-ref-format to check if a ref name is valid. As the doc says, [ is not valid. And in your case, a space and a colon are also invalid.

They cannot have ASCII control characters (i.e. bytes whose values are lower than \040, or \177 DEL), space, tilde ~, caret ^, or colon : anywhere.

They cannot have question-mark ?, asterisk *, or open bracket [ anywhere. See the --refspec-pattern option below for an exception to this rule.

You can test a branch by git check-ref-format --branch '<branchname>'.

git check-ref-format --branch '[#3]feature:filter'
fatal: '[#3]feature:filter' is not a valid branch name
ElpieKay
  • 27,194
  • 6
  • 32
  • 53