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
Which characters are illegal within a branch name?
提问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:
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 likeheads/
,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
\
.
Git 对引用的命名方式施加了以下规则:
它们可以包含
/
用于分层(目录)分组的斜杠,但斜杠分隔的组件不能以点开头.
或以序列 结尾.lock
。它们必须至少包含一个
/
. 这会强制存在诸如等之类的类别heads/
,tags/
但实际名称不受限制。如果使用该--allow-onelevel
选项,则放弃此规则。他们不能在
..
任何地方有两个连续的点。它们在任何地方都不能有 ASCII 控制字符(即值小于
\040
, 或 的字节\177
DEL
)、空格、波浪号~
、插入符号^
或冒号:
。它们不能在任何地方有问号
?
、星号*
或左括号[
。有关--refspec-pattern
此规则的例外情况,请参阅下面的选项。它们不能以斜杠开头或结尾,也不能
/
包含多个连续的斜杠(请参阅--normalize
下面的选项以了解此规则的例外情况)它们不能以点结尾
..
它们不能包含序列
@{
。它们不能是单个字符
@
。它们不能包含
\
.
On top of that, additional rule for branch name:
最重要的是,分支名称的附加规则:
- They cannot start with a dash
-
- 他们不能以破折号开头
-
Thanks to Jakub Nar?bski, the man pagefor git check-ref-format
has more details.
感谢的Jakub纳尔?bski,该手册页的git check-ref-format
细节更加丰富。