gpt4 book ai didi

git - 哪些名称是有效的 git 标签?

转载 作者:IT王子 更新时间:2023-10-29 00:37:51 26 4
gpt4 key购买 nike

我在创建包含 [ 字符的标签时收到错误消息:

fatal: '[' is not a valid tag name.

问题:git中的tags有什么规则吗?

最佳答案

您可以检查名称是否有效

git check-ref-format

page包含对有效名称的约束。引自页面(将来可能已过时):

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

如您所见,您违反了规则 (5)。

您可以使用 --normalize标记以根据斜杠规范化标签(删除前导斜杠和连续斜杠):

git check-ref-format --normalize "tags/weird//tag"

tags/您正在验证的零件种类 tag .

与@NikosAlexandris 讨论后,您可以编写以下一行代码来检查标签 <some-tag>带有文本反馈:

git check-ref-format "tags/<some-tag>" && echo "Valid tag" || echo "Invalid tag"

关于git - 哪些名称是有效的 git 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26382234/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com