如何用Git推送一个标签到远程仓库?

我克隆了一个远程Git仓库到我的笔记本上,然后我想添加一个标签,所以我运行了

git tag mytag master

当我在笔记本上运行git tag时,显示了mytag的标签。然后我想把它推送到远程仓库,这样我的所有客户端都有这个标签,所以我运行了git push,但我得到的消息是。

一切都是最新的

如果我去我的桌面,运行git pull,然后git tag,没有标签显示。

我还试着对项目中的一个文件做了一个小改动,然后把它推送到服务器上。之后,我可以把改动从服务器拉到我的桌面电脑上,但在我的桌面电脑上运行git tag时仍然没有标签。

我怎样才能把我的标签推送到远程仓库,让所有客户电脑都能看到它?

要推动一个***的标签。

git push origin 

而下面的命令应该推送*的所有标签(不推荐**)。

git push --tags
评论(7)
解决办法

git push --follow-tags

这是 Git 1.8.3 中引入的一个合理的选项。

git push --follow-tags

它既推送提交,又只推送两者都是的标签。

  • 注释的
  • 中的可达到(祖先)。

这是很正常的,因为。

  • 你应该只向远程推送注释的标签,并保留轻量级的标签用于本地开发,以避免标签冲突。 也可以参考。 https://stackoverflow.com/questions/11514075
  • 它不会在不相关的分支上推送注释的标签

基于这些原因,应该避免使用--tags

Git 2.4 增加了 `push.followTags'选项,可以通过以下方式设置默认开启该标志。

git config --global push.followTags true
评论(7)

要推送特定的一个标签,请执行以下操作 git push origin tag_name

评论(0)

拓展一下[Trevor'的回答][回答],你可以推送单个标签或你所有的 一次推送一个标签。

##推送单个标签

git push  

这是解释这个问题的[相关文档][doc]的摘要(有些 为了简洁起见,省略了命令选项)。)

git push [[]: > git push [[ [...]] 。

...。 >.参数的格式是 ``参数的格式是…源参考``。 `>.`,> 后面跟着一个冒号`:`,后面是目的地ref``&hellip。 。 >。 ``告诉远端的哪个ref会被更新。 >.推送…。 push…如果省略了`:`,则会有与``相同的引用。

更新&hellip。 更新了…。

标签<tag>refs/tags/<tag>:refs/tags/<tag>意思相同。

一次推送所有的标签

git push --tags 
# Or
git push  --tags

以下是[相关文档][doc]的摘要(一些命令选项 为简洁起见省略了)。)

git push [--all | --mirror git push [--all | --mirror | --tags] [ [...]] 。

-tags; --tags

除了显式的refspecs之外,"refs/tags "下的所有refs都会被推送。

在命令行中列出。

[doc]: https://www.kernel.org/pub/software/scm/git/docs/git-push.html 答案】。 https://stackoverflow.com/a/5195913/456814

评论(4)

git push命令不会将标签发送到远程仓库。 我们需要使用下面的命令将这些标签明确地发送给远程服务器。

git push origin 

我们可以通过下面的命令一次性推送所有的标签。

git push origin --tags

这里有一些关于git标签的完整细节的资源。

http://www.cubearticle.com/articles/more/git/git-tag

http://wptheming.com/2011/04/add-remove-github-tags

评论(0)

你可以像这样推送标签git push --tags

评论(0)

您可以通过 "git push --tags "命令推送所有本地标签。

$ git tag                         # see tag lists
$ git push origin       # push a single tag
$ git push --tags                 # push all local tags 
评论(0)

我使用git push <remote-name> tag <tag-name>来确保我推送的是一个标签。 我的使用方法如下 git push origin tag v1.0.1。 这个模式是基于文档 (man git-push)。

OPTIONS
   ...
   ...
       ...
       tag  means the same as refs/tags/:refs/tags/.
评论(1)