【问题标题】:When must the tag be set for github push?什么时候必须为 github push 设置标签?
【发布时间】:2017-06-18 11:13:41
【问题描述】:

我不明白如何在 git 中正确标记版本,因此版本与标记一起推送到 github。

事实上,我什至不知道设置标签名称的正确时机。

需要在本地提交之前还是本地提交之后设置标签?

我已经认真检查了 git 文档。

然后,当我想推送到远程(即 github)时,我是否需要再次设置标签名称,如下例所示:

https://stackoverflow.com/a/5195913/716568

有没有办法自动推送与当前设置的本地标签同步?

【问题讨论】:

    标签: git github tagging


    【解决方案1】:

    我找到了两种方法。

    1.

    $ git add .
    $ git commit -m "a msg"
    $ git push origin master tag v1.0.0
    

    2.

    $ git add .
    $ git commit -m "msg"
    $ git tag v1.0.1
    $ git push origin master --tags
    

    您可以像这样向标签添加消息:

    $ git tag v2.0.0 -m "second release"
    $ git push origin master tag v2.0.0
    

    但据我所知,将标签显示为最新版本的唯一方法是在 github.com 上为其添加标题

    您可以通过$ git help tag$ git help push 找到更多信息

    【讨论】:

      【解决方案2】:

      设置标签名称的最佳时机是在创建标签时。您可以随时创建和推送它。您可以在提交后或一周后立即创建标签。由你决定。

      当您想通过提交推送标签时,您可以在命令行中命名标签(例如git push origin master tag v3.42),或者您可以将 push.followTags=true 添加到配置中:git config [--global] push.followTags true ([--global]意味着可选——您必须决定是要在全局配置(每个用户)文件还是本地(每个 repo)中进行设置;使用此设置 git 在推送这些标签指向的提交时会推送标签。

      您可以单独推送一个标签:git push origin tag v3.42。 Git 将推送标签和完成分支所需的所有提交。

      【讨论】:

      • 谢谢,很好的解释和澄清。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-03
      • 2014-11-08
      • 2013-10-23
      • 1970-01-01
      • 2011-03-18
      • 2012-04-26
      相关资源
      最近更新 更多