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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3651860/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 09:03:13  来源:igfitidea点击:

Which characters are illegal within a branch name?

gitbranchnaming

提问by lunohodov

Which characters are illegal within a branch name?

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

回答by Manoj Govindan

Naming rules for refname:

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-oneleveloption 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 \177DEL), space, tilde ~, caret ^, or colon :anywhere.

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

  6. They cannot begin or end with a slash /or contain multiple consecutive slashes (see the --normalizeoption 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 \.

Git 对引用的命名方式施加了以下规则:

  1. 它们可以包含/用于分层(目录)分组的斜杠,但斜杠分隔的组件不能以点开头.或以序列 结尾.lock

  2. 它们必须至少包含一个/. 这会强制存在诸如等之类的类别heads/tags/但实际名称不受限制。如果使用该--allow-onelevel选项,则放弃此规则。

  3. 他们不能在..任何地方有两个连续的点。

  4. 它们在任何地方都不能有 ASCII 控制字符(即值小于\040, 或 的字节\177DEL)、空格、波浪号~、插入符号^或冒号:

  5. 它们不能在任何地方有问号?、星号*或左括号[。有关--refspec-pattern此规则的例外情况,请参阅下面的选项。

  6. 它们不能以斜杠开头或结尾,也不能/包含多个连续的斜杠(请参阅--normalize下面的选项以了解此规则的例外情况)

  7. 它们不能以点结尾 ..

  8. 它们不能包含序列@{

  9. 它们不能是单个字符@

  10. 它们不能包含\.

On top of that, additional rule for branch name:

最重要的是,分支名称的附加规则:

  1. They cannot start with a dash -
  1. 他们不能以破折号开头 -

Thanks to Jakub Nar?bski, the man pagefor git check-ref-formathas more details.

感谢的Jakub纳尔?bski,该手册页git check-ref-format细节更加丰富。