我在我的机器上的主分支中添加了一个标签:
git tag mytag master
我该如何将这个推送到远程仓库?运行 git push
后显示:
Everything up-to-date
但是,远程仓库并不包含我的标签。
要推送一个单独的标签:
git push origin <tag_name>
以下命令应该会推送所有标签(不建议使用):
# not recommended
git push --tags
git push --follow-tags
--tags
选项。push.followTags
选项,默认情况下启用该选项,你可以通过以下方式进行设置:git config --global push.followTags true
或者通过将followTags = true
添加到您的~/.gitconfig
文件的[push]
部分来实现。
要在Visual Studio Code中激活此功能,请在用户或工作区基础上设置变量"git.followTagsWhenSync": true
。GitHub
git push origin --tags
可以。 - nnyby如果要推送特定的标签,执行以下操作:
git push origin tag_name
git push <remote> <tag>
git push [[<repository> [<refspec>…]] <refspec>...
The format of a
<refspec>
parameter is…the source ref<src>
, followed by a colon:
, followed by the destination ref<dst>
…The
<dst>
tells which ref on the remote side is updated with this push…If:<dst>
is omitted, the same ref as<src>
will be updated…tag
<tag>
means the same asrefs/tags/<tag>:refs/tags/<tag>
.
git push --tags <remote>
# Or
git push <remote> --tags
git push [--all | --mirror | --tags] [<repository> [<refspec>…]] --tags
All refs under
refs/tags
are pushed, in addition to refspecs explicitly listed on the command line.
tag
。例如:git push origin tag funny-tag-1
。 - JamesThomasMoongit push origin my-tag
(我刚试过了!) - Andres F.2.10.2
。也许就是这样了? - Andres F.在当前分支中添加一个标签。如果您想为主分支创建标签,请先切换到主分支。
git tag tag_name
检查是否已创建
git tag
将你的远程仓库推送
git push origin tag_name
git push --tags
命令推送所有本地标签。$ git tag # see tag lists
$ git push origin <tag-name> # push a single tag
$ git push --tags # push all local tags
使用git push命令不会将标签发送到远程存储库。我们需要使用以下命令显式地将这些标签发送到远程服务器:
git push origin <tagname>
我们可以使用以下命令一次性地推送所有标签:
git push origin --tags
以下是有关Git标记的完整详细信息资源:
git push --tags
如何将我的标签推送到远程仓库,以便所有客户端计算机都可以看到它?
运行以下命令将mytag
推送到您的 Git 远程源(例如:GitHub 或 GitLab)
git push origin refs/tags/mytag
最好像上面展示的一样使用完整的“refspec”(字面上为refs/tags/mytag
),以防mytag
实际上是模糊的(例如:因为还有一个名为v1.0.0
的分支)。
我使用git push <remote-name> tag <tag-name>
来确保我正在推送一个标签。 我的使用方式是:git push origin tag v1.0.1
。 这种模式基于文档(man git-push
)。
OPTIONS
...
<refspec>...
...
tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>.
git push --tags
,因为一旦你的同事习惯了推送所有标签,当你需要摆脱错误标签时就会变得非常困难。每次他们想要推送新标签的时候,都会将本地保存的旧的错误标签推送上去。因此,现在我只会建议别人使用git push origin <tag_name>
。 - Scott Jungwirthgit push origin <tag_name> --force
- Bob Steingit push
失败并显示error: src refspec <tag_name> matches more than one.
,您可以使用git push origin tag <tag_name>
进行推送。 - Volodymyr Sapsaigit push --tags origin <tag_name>
并不是 你想要的操作 - 即使它命名了一个特定的标签,它仍会将所有标签一起推送,包括轻量级标签。叹气。 - nealmcbgit push --dry-run --tags origin
来查看将要被推送的内容。请注意,此命令不会实际执行推送操作,只是显示将要被推送的标签信息。 - axxisgit push origin <tag_name>
对我不起作用。git push origin refs/tags/<tag_name>
可以工作。 - user2027712