Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which characters are illegal within a branch name?

Tags:

git

branch

naming

Which characters are illegal within a branch name?

like image 535
lunohodov Avatar asked Sep 06 '10 13:09

lunohodov


People also ask

Are spaces allowed in git branch names?

Creating a New Branch In Git, the git branch branch-name command is used to create a new branch called branch-name . Branches should be named something that describes the purpose of the branch. Note that branch names can't contain whitespace: new-feature and new_feature are valid branch names, but new feature is not.

Should branch names be lowercase?

Branch NamingUse only lower case alphanumeric characters. Use '-' rather than spaces or underscores.


1 Answers

Naming rules for refname:

Git imposes the following rules on how references are named:

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

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

  3. They cannot have two consecutive dots .. anywhere.

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

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

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

  7. They cannot end with a dot .

  8. They cannot contain a sequence @{.

  9. They cannot be the single character @.

  10. They cannot contain a \.

On top of that, additional rule for branch name:

  1. They cannot start with a dash -

Thanks to Jakub Narębski, the man page for git check-ref-format has more details.

like image 111
Manoj Govindan Avatar answered Oct 08 '22 18:10

Manoj Govindan