什么名字是有效的git标签? [英] What names are valid git tags?

查看:78
本文介绍了什么名字是有效的git标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建包含[字符的标记时出现错误消息:

I have got a error message while creating tag containing [ character:

致命:'['不是有效的标签名称.

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

问题:git中的标签有任何规则吗?

Question: are there any rules for tags in the git?

推荐答案

您可以检查名称是否有效

You can check if the name is valid with

git check-ref-format

页面包含对有效名称的限制.从页面引用(将来可能会过时):

This page contains the constraints on a valid name. Quoted from the page (possibly outdated in the future):

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

  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.

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

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.

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

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

在任何地方都不能有问号?,星号*或方括号[.有关此规则的例外,请参见下面的--refspec-pattern选项.

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

它们不能以斜杠/开头或结尾,也不能包含多个连续的斜杠(有关此规则的例外,请参见下面的--normalize选项)

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

它们不能以点号.结尾.

它们不能包含序列@{.

它们不能是单个字符@.

它们不能包含\.

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

As you can see, in your case you violated rule (5).

您可以使用--normalize标志针对斜杠(删除前导斜杠和连续斜杠)对标签进行归一化:

You can use the --normalize flag to normalize tags with respect to slashes (removing leading slashes as well as consecutive ones):

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

您正在验证tagtags/部分种类.

The tags/ part species that you are validating a tag.

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

After some discussion with @NikosAlexandris, you can write the following one liner to check the tag <some-tag> with textual feedback:

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

这篇关于什么名字是有效的git标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆