如果你看看git的代码(下面的链接),我们可以看到,推它正在检查关键字标签期间。
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);
}
}
如果你混帐推的文档中查找(即做'混帐推--help'。并搜索标签)。你会看到'git push'有一个特定的关键字,你可以用它明确指定你可以用来推送标签。这个关键字就是'tag'(惊喜!)。所以,理论上你可以做'git push tag tag',第一个'tag'是关键字,第二个'tag'是标签名。但是,我同意下面的答案:命名标签'tag'是不可取的。 – Alderath
我只尝试过“git push -tag tag”和“git push --tag tag”。 谢谢! :) – forestgril