我在主分支上创建了一个名为 v0.1
的标签,如下所示:
git tag -a v0.1
但后来我意识到我仍然需要将一些更改 merge 到 0.1 版本的 master 中,所以我这样做了。但是现在我的 v0.1
标记卡在了错误的提交上(调用便利贴类比)。我希望它停留在 master 上最近的提交上,但它却停留在 master 上的第二个最近提交上。
如何将它移动到 master 上的最新提交?
最佳答案
使用 -f
选项来 git tag
:
-f
--force
Replace an existing tag with the given name (instead of failing)
您可能希望结合使用 -f
和 -a
来强制创建带注释的标签,而不是非带注释的标签。
例子
在推送之前删除任何 Remote 上的标签
git push origin :refs/tags/<tagname>
替换标签以引用最近的提交
git tag -fa <tagname>
将标签推送到远端
git push origin master --tags
关于git - 如何将 git 分支上的标签移动到不同的提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8044583/