关于git:分支名称中哪些字符是非法的?

Which characters are illegal within a branch name?

分支名称中哪些字符是非法的?


refname的命名规则:

Git imposes the following rules on how references are named:

  • They can include slash / for hierarchical (directory) grouping, but no slash-separated component can begin with a dot . or end with the sequence .lock.

  • They must contain at least one /. This enforces the presence of a category like heads/, tags/ etc. but the actual names are not restricted. If the --allow-onelevel option is used, this rule is waived.

  • They cannot have two consecutive dots .. anywhere.

  • 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.

  • They cannot begin or end with a slash / or contain multiple consecutive slashes (see the --normalize option below for an exception to this rule)

  • They cannot end with a dot ..

  • They cannot contain a sequence @{.

  • They cannot be the single character @.

  • They cannot contain a \.

  • 除此之外,分支名称的附加规则:

  • They cannot start with a dash -
  • 感谢Jakub Nar?bski,git check-ref-format的手册页有更多的细节。