[英]Tag a git commit with a "tag" tag
我使用以下命令用名为“tag”的标签标记我的 HEAD:
git tag -a tag -m "comment on my tag"
但是当我
git push origin tag
我收到一个错误:
致命:没有<标签>的标签速记
对于具有不同名称的标签,我没有收到相同的错误。 我想 git 把这个“标签”当作它的子命令。 也许这不是一个经常使用的案例……但是是否可以将“标签”推送到远程仓库? 我不想推送我的其他标签
git push --tags
尽管!
如果您查看 git 代码(下面的链接),我们可以看到在推送期间它正在检查关键字tag 。
https://github.com/tnachen/git/blob/master/builtin/push.c
简短回答:给标签一个有意义的名字,不要使用 git 关键字
static void set_refspecs(const char **refs, int nr)
{
int i;
for (i = 0; i < nr; i++) {
const char *ref = refs[i];
if (!strcmp("tag", ref)) {
char *tag;
int len;
if (nr <= ++i)
die("tag shorthand without <tag>");
len = strlen(refs[i]) + 11;
if (deleterefs) {
tag = xmalloc(len+1);
strcpy(tag, ":refs/tags/");
} else {
tag = xmalloc(len);
strcpy(tag, "refs/tags/");
}
strcat(tag, refs[i]);
ref = tag;
} else if (deleterefs && !strchr(ref, ':')) {
char *delref;
int len = strlen(ref)+1;
delref = xmalloc(len+1);
strcpy(delref, ":");
strcat(delref, ref);
ref = delref;
} else if (deleterefs)
die("--delete only accepts plain target ref names");
add_refspec(ref);
}
}
这就是我所做的:
之后我删除了标签分支。
希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.