交换“最新版本”在github上 [英] Swap "Latest release" on github

查看:116
本文介绍了交换“最新版本”在github上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在github上有一个 在前一个提交中添加标签( git tag -a v0.1.0 b217332279 -mrelease 0.1.0

  • 将标签( git push --tags origin master

  • 通过发布发布新版本 v0.2.0 标记并获得



    解决方案

    我不知道有什么方法直接在GitHub中执行此操作。 最新版本是根据您的代码上的时间戳确定的,而不是来自它们名称的语义。



    在过去,我已经在我自己的个人项目中解决了这个问题通过删除有问题的旧标签:

      git tag -d v0.1.0 
    git push --delete origin v0。 1.0

    并用假日期重新创建它:

      GIT_COMMITTER_DATE =2013-12-31 00:00git tag -a v0.1.0.1 b217332279 -mrelease 0.1.0.1
    git push - 标签来源大师

    这在 git-tag 的手册页:


    On Backdating Tags



    如果您从其他VCS导入了一些更改并希望为主要版本添加标签,能够指定要在标签对象内嵌入的日期非常有用;例如,标签对象中的这些数据会影响到gitweb界面中标签的排序。为了设置未来标签对象中使用的日期,设置环境变量GIT_COMMITTER_DATE (请参阅后面对可能值的讨论;最常用的形式是YYYY-MM-DD HH:MM)。

    例如:


    $ b

      $ GIT_COMMITTER_DATE =2006-10-02 10:31git tag -s v1.0.1 


    请注意,同样的手册页强烈建议反对重复使用相同的标记名称:


    关于重新标记



    当您标记错误提交时应该怎么做,想要重新标记?



    如果您从未推出任何内容,只需重新标记即可。用-f替换旧的。你完成了。



    但是,如果你推出了一些东西(或者其他人可以直接读取你的存储库),那么其他人就会看到旧的标签。在这种情况下,您可以执行以下两件事之一:


    1. 理智的事情。只要承认你搞砸了,并使用不同的名字。其他人已经看到一个标签名称,如果你保持相同的名称,你可能处于两个人都拥有版本X的情况,但他们实际上有不同的X。所以就把它叫做X.1,然后用它来做。

    2. 疯狂的东西。即使其他人已经看过旧版本,你也确实想要叫新版本X。因此,只要使用 git tag -f again ,就好像您还没有发布旧的。




      但是,Git不会 (它不应该)更改用户背后的标签。所以如果有人已经得到了旧标签,在树上做一个 git pull 不应该让它们覆盖旧标签。



      如果有人获得了您的发布标签,您不能通过更新自己的标签来更改标签。这是一个很大的安全问题,因为人们必须能够信任他们的标签名称。如果你真的想要做这个疯狂的事情,你只需要付诸行动,并告诉人们你搞砸了。你可以通过发表一个非常公开的声明来做到这一点:


      好吧,我搞砸了,我推出了一个标签为X 。
      然后修正了一些内容,并且将固定的树重新固定为X.



      如果你得到了错误的标签,并且想要新的,请删除旧的
      并通过执行来获取新的:

        git tag -d X 
      git fetch原始标记X

      可以获取我的更新标记。



      你可以测试你使用哪个标签

        git rev-parse X 

      如果您有新版本,应该返回0123456789abcdef ..



      不便之处。

      这看起来有点复杂吗?它应该。没有办法自动修复它是不正确的。人们需要知道他们的标签可能已经被更改。

    如果您的项目相对孤立,我只会重复使用相同的标签,而您可以可靠地联系每个可能使用代码的人。



    有关删除远程标签的更多详细信息,请参阅这个问题


    I have a repository on a github.

    Here is the graph:

    Here is my action sequence:

    1. Make 5 commits and push them

    2. Add a tag v0.2.0 (git tag -a v0.2.0 -m "release 0.2.0")

    3. Push the tag (git push --tags origin master)

    4. Make a release by Draft a new release button on github site. I have selected v0.2.0 tag and got https://github.com/n1k1ch/PrototypeGit/releases/tag/v0.2.0

    5. Add a tag to previous commit (git tag -a v0.1.0 b217332279 -m "release 0.1.0")

    6. Push the tag (git push --tags origin master)

    7. Make a release by Draft a new release with v0.2.0 tag and got https://github.com/n1k1ch/PrototypeGit/releases/tag/v0.1.0

    So, v0.1.0 tag become Latest release

    Question:

    Am I able to swap v0.1.0 release with v0.2.0 release, to v0.2.0 become the Latest release?


    P.S. googling "github swap release" didn't help


    Edit:

    Thanks to @Chris, i did it. One small note - on Windows i used:

    SET GIT_COMMITTER_DATE="2014-04-02 23:00"
    git tag -a v0.1.0 b217332279 -m "release 0.1.0"
    git push --tags origin master
    

    Just if someone interested, after this i see following:

    I opened v0.1.0 and press Publish release The result is:


    Also i have received the answer from support@github.com:

    This is expected behavior. We're going by the date of your v0.1.0 release, not the date of the last commit. Here's a good blog post about changing the date of an annotated tag: http://sartak.org/2011/01/replace-a-lightweight-git-tag-with-an-annotated-tag.html

    解决方案

    I am not aware of any way to do this directly in GitHub. The "latest release" is determined from the timestamps on your tags, not from the semantics of their names.

    In the past I have solved this problem on my own personal projects by deleting the problematic older tag:

    git tag -d v0.1.0
    git push --delete origin v0.1.0
    

    and recreating it with a fake date:

    GIT_COMMITTER_DATE="2013-12-31 00:00" git tag -a v0.1.0.1 b217332279 -m "release 0.1.0.1"
    git push --tags origin master
    

    This is documented in the manpage for git-tag:

    On Backdating Tags

    If you have imported some changes from another VCS and would like to add tags for major releases of your work, it is useful to be able to specify the date to embed inside of the tag object; such data in the tag object affects, for example, the ordering of tags in the gitweb interface.

    To set the date used in future tag objects, set the environment variable GIT_COMMITTER_DATE (see the later discussion of possible values; the most common form is "YYYY-MM-DD HH:MM").

    For example:

    $ GIT_COMMITTER_DATE="2006-10-02 10:31" git tag -s v1.0.1
    

    Note that this same manpage strongly recommends against reusing the same tag name:

    On Re-tagging

    What should you do when you tag a wrong commit and you would want to re-tag?

    If you never pushed anything out, just re-tag it. Use "-f" to replace the old one. And you're done.

    But if you have pushed things out (or others could just read your repository directly), then others will have already seen the old tag. In that case you can do one of two things:

    1. The sane thing. Just admit you screwed up, and use a different name. Others have already seen one tag-name, and if you keep the same name, you may be in the situation that two people both have "version X", but they actually have different "X"'s. So just call it "X.1" and be done with it.

    2. The insane thing. You really want to call the new version "X" too, even though others have already seen the old one. So just use git tag -f again, as if you hadn't already published the old one.

    However, Git does not (and it should not) change tags behind users back. So if somebody already got the old tag, doing a git pull on your tree shouldn't just make them overwrite the old one.

    If somebody got a release tag from you, you cannot just change the tag for them by updating your own one. This is a big security issue, in that people MUST be able to trust their tag-names. If you really want to do the insane thing, you need to just fess up to it, and tell people that you messed up. You can do that by making a very public announcement saying:

    Ok, I messed up, and I pushed out an earlier version tagged as X. I then fixed something, and retagged the fixed tree as X again.

    If you got the wrong tag, and want the new one, please delete the old one and fetch the new one by doing:

    git tag -d X  
    git fetch origin tag X
    

    to get my updated tag.

    You can test which tag you have by doing

    git rev-parse X
    

    which should return 0123456789abcdef.. if you have the new version.

    Sorry for the inconvenience.

    Does this seem a bit complicated? It should be. There is no way that it would be correct to just "fix" it automatically. People need to know that their tags might have been changed.

    I would only reuse the same tag if your project is relatively isolated and you can reliably contact everybody who may be using the code.

    For more details about deleting remote tags have a look at this question.

    这篇关于交换“最新版本”在github上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆