代码之家  ›  专栏  ›  技术社区  ›  Kagemand Andersen

Git标记真的是(refs/tag)[重复]

  •  0
  • Kagemand Andersen  · 技术社区  · 6 年前

    git tag 1.5 1.0
    git tag -d 1.0
    git push origin :refs/tags/1.0
    

    git describe 输出:

    warning: tag '1.0' is really '1.5' here
    1.0-97-g88085b2
    

    它应该会回来 1.5-... 现在

    这个 git fsck --tags 输出:

    Checking object directories: 100% (256/256), done.
    tagged commit aad9477bba4bcf44ea34ea9693aeffc98527ff01 (1.0) in b96ce67583239e198f9e2aff5175176d65779044
    Checking objects: 100% (3975/3975), done.
    

    0 回复  |  直到 12 年前
        1
  •  32
  •   Community Tales Farias    7 年前

    我几分钟前也遇到过同样的问题。已经给出的答案中没有一个涉及到 那就是把信息去掉 warning: tag 'foo' is really 'bar' here git describe git描述 将用于生成的源记录到生成中。

    复制问题

    我可以通过这样做来复制问题:

    $ git tag foo --annotate -m"original message"
    $ git tag bar foo
    $ git tag -d foo
    $ git describe 
    warning: tag 'foo' is really 'bar' here
    foo
    

    --annotate 上面的标志是多余的 -m 暗示 我曾尝试用一个轻量级标记来复制这个问题,但没有成功。因此,要复制这个问题,需要一个注释。

    其中有些涉及到推倒那些已经推倒的事情,但我发现我自己同意大卫·卡普的观点 he says

    然而,有时它只是不值得长期的痛苦不准确(混乱)的历史和短期的痛苦是值得的。

    警告:这里的标签“foo”实际上是“bar” ,则必须执行以下操作:

    $ git tag bar bar -m"original message" --force
    $ git describe 
    bar
    

    如果消息需要更改,则根据需要进行调整。

    要删除已推送的旧标记,请执行以下操作:

    $ git push origin :refs/tags/foo
    

    要在新标记已被推送时更新它,请执行以下操作:

    $ git push origin refs/tags/bar
    

    避免问题

    首先要避免这个问题,你必须创造 bar 使用:

    $ git tag bar foo -m"original message"
    
        2
  •  2
  •   David Culp    12 年前

    每当有人建议重写历史记录(或者在本例中,重新标记历史记录)时,重申标准警告——如果可以避免,就不要这样做。

    然而,有时它只是不值得长期的痛苦不准确(混乱)的历史和短期的痛苦是值得的。

    如果是这样,下面的文章给出了所需的步骤: How to Rename a Tag Already Pushed to a Remote git Repo .

    基本步骤是:

    git tag new_tag old_tag
    git push --tags
    git push origin :refs/tags/old_tag
    git tag -d old_tag
    
        3
  •  1
  •   broofa    5 年前

    release-it . 在我的远程repo中,对于相同的标记名,有轻量级和带注释的标记项:

    $ git ls-remote --tags origin
    302883ef0cb2df8975abfbd24bbe89f64cf3da31    refs/tags/0.0.1
    4852192308b404d74d7a4088c19a4629299f6ea2    refs/tags/0.0.1^{}
    

    ^{} 在第二个条目上的标记名之后)

    这对于带注释的标记(?)来说似乎是正常的,所以不要认为这本身就是问题所在,但是在我删除所有标记并重新标记所有内容之后,问题就消失了。例如,对于上面的标签。。。

    git tag -d 0.0.1                # Delete local tag
    git push --delete origin 0.0.1  # Delete remote tag
    git tag -a -m "" 0.0.1 4852192308b404d74d7a4088c19a4629299f6ea2  # Recreate [annotated] tag
    git push --tags                 # Push tag(s) to remote repo
    
        4
  •  -3
  •   Mike Monkiewicz    12 年前

    不,我不认为这是git中标签的正确工作流程。

    不要弄乱你已经推过的东西。