gpt4 book ai didi

Git 重新标记理智和疯狂的建议 - 第 2 部分

转载 作者:太空狗 更新时间:2023-10-29 12:54:16 26 4
gpt4 key购买 nike

当我阅读有关重命名 git 标签的内容时,许多人指向阅读 this :

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:

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.

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.

好吧,关于重新标记,如果您有兴趣,我问了一个较早的问题 - Git retagging sane and insane advice - Part 1 , 但是,这不是必需的。我刚刚将问题链接起来,因为上下文相同。

所以,我的问题是

我有一个远程仓库的 2 个本地仓库 - 仓库 1 和仓库 2。

第 1 步:在 repo1 中创建带注释的标签,名称为 X

第 2 步:推送到远程。

第 3 步:Repo 2 pull 标签。

第 4 步:Repo 1 删除标签 X 并创建另一个标签 X 但这次使用不同的消息。

第 5 步:推送到远程。

第 6 步:在 repo2 中,git pull --tags 更新标签 X。

这怎么可能?正如上面强调的那样,git 不应该这样做——更新标签?

最佳答案

So if somebody already got the old tag,

这是你的第 3 步。

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.

旧版本有效 - 一切都很好。推送后无法更改标签。

关于Git 重新标记理智和疯狂的建议 - 第 2 部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50369105/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com