git重新标记理智和疯狂的建议 [英] Git retagging sane and insane advice

查看:73
本文介绍了git重新标记理智和疯狂的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我在阅读有关git标签重命名的内容,但许多人指出:

While I was reading about renaming of git tags , many people pointed to read this :

但是,如果您将内容推送出去(否则其他人可能只是阅读您的 直接存储库),那么其他人将已经看到了旧标记. 在这种情况下,您可以执行以下两项操作之一:

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:

理智的事情.

只需承认您搞砸了,并使用其他名称即可. 其他人已经看到了一个标记名,如果您保持相同的名称, 您可能处于两个人都拥有"X版本"的情况,但是 它们实际上具有不同的"X".因此,只需将其称为"X.1"即可并完成

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.

疯狂的事情.

您真的想将新版本称为"X",也, 即使其他人已经看过旧的.所以只用git标签 -f,就好像您尚未发布旧版本一样.

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.

但是,Git不会(也不应该)更改用户背后的标签 背部.因此,如果有人已经获得了旧标签,请在您的git上进行git pull 一棵树不应该只是让它们覆盖旧的树.

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.

我不确定我是否会完全遵循.

I am not sure if I followed this completely.

Q)在理智的意义上,他的意思是- 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.

Q) In sane thing what does he mean by - 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.

用疯狂的话说,如果我将标签名保持不变并强制执行push,则git pull不会更新具有该旧标签的同事.因此,他的意思是-you may be in the situation .....可能是什么情况?

In insane thing , it is written that if I keep the tag name same and force push , git pull won't update my coworkers having that old tag. Hence what does he mean by - you may be in the situation .... . What can be the situation ?

推荐答案

假设分支的历史记录为A-B-C.您在B上创建标签foo并将其推送到远程存储库. Bob获取分支并获取指向B的标签foo.

Suppose a branch has the history of A-B-C. You make a tag foo on B and push it to the remote repository. Bob fetches the branch and gets the tag foo which points to B.

之后,您发现该标签应该位于C上.因此,您可以在C上重新标记foo并将其强制推送到远程存储库,但不会告诉其他人.玛丽获取分支并获取标记foo,该标记插入C.

Later you find that the tag should have been on C. So you retag foo on C and force-push it to the remote repository but tells nobody else. Mary fetches the branch and gets the tag foo which poinst to C.

从您的发行说明中,Bob和Mary知道版本foo是一个稳定的修订版,因此他们在自己的存储库中检出了foo.如果BC恰好具有相同的树,这意味着代码相同,那么您很幸运.但是,很可能它们具有不同的树.在这种情况下,鲍勃和玛丽从foo获得了不同的代码,而他们对此一无所知.

From your release note Bob and Mary get to know that the version foo is a stable revision so they checkout foo in their own repositories. If B and C happen to have the same tree which means the codes are the same, you are just lucky. However most probably they have different trees. This is the situation where Bob and Mary get different codes from foo and they don't know about it.

Bob可能会发现一个已在C中修复的错误,并告诉Mary,但Mary告诉Bob她无法重现该错误.鲍勃(Bob)说他签出foo,玛丽(Mary)也这样做.可能需要避免一些努力才能找出真正的原因.当越来越多的人获得名称相同但指向不同提交的标签时,情况将变得更糟.

Bob may find a bug which has been fixed in C and tells Mary about it, but Mary tells Bob that she can't reproduce the bug. Bob says he checks out foo, and Mary says so does she. It may take effort that could have been avoided to find out the real reason. It gets worse when more people get the tags that have the same name but point to different commits.

这篇关于git重新标记理智和疯狂的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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