可以将轻量级标签转换为带注释的标签吗? [英] Can a lightweight tag be converted to an annotated tag?
问题描述
我用轻量级标签标记了一个提交,并将该标签推送到一个远程仓库,与其他开发人员共享.我现在意识到我应该对它进行注释,以便它出现在 git describe
中.
I've tagged a commit with a lightweight tag, and pushed that tag to a remote repo, shared with other developers. I have now realised I should have annotated it so that it appears in git describe
.
有没有办法在不破坏任何东西的情况下转换它/重新标记提交?
Is there a way to convert it/re-tag the commit without breaking things?
推荐答案
轻量级标记只是指向该提交的引用".您可以在旧标签之上强制创建一个新的注释标签:
A lightweight tag is just a 'ref' that points at that commit. You can force-create a new annotated tag on top of the old tag:
git tag -a -f <tagname> <tagname>
从 Git v1.8.2 开始,您需要使用 --force
将遥控器上的任何标签替换为 git push
,即使您正在替换轻量级标签具有有效的快进或真正的标签对象,指向与现有标签引用相同的提交.
As of Git v1.8.2, you need to use --force
to replace any tags on a remote with git push
, even if you are replacing a lightweight tag with something that is effectively a fast-forward or a true tag object pointing at the same commit as the existing tag reference.
git push --force origin <tagname>
这篇关于可以将轻量级标签转换为带注释的标签吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!