Here is how I rename a tag old
to new
:
(这是我将old
标签重命名为new
标签的方法:)
git tag new old
git tag -d old
git push origin :refs/tags/old
git push --tags
The colon in the push command removes the tag from the remote repository.
(push命令中的冒号将从远程存储库中删除标记。)
If you don't do this, Git will create the old tag on your machine when you pull. (如果您不这样做,当您拉时,Git将在您的机器上创建旧标签。)
Finally, make sure that the other users remove the deleted tag.
(最后,请确保其他用户删除了已删除的标签。)
Please tell them (co-workers) to run the following command: (请告诉他们(同事)运行以下命令:)
git pull --prune --tags
Note that if you are changing an annotated tag , you need ensure that the new tag name is referencing the underlying commit and not the old annotated tag object that you're about to delete.
(请注意, 如果要更改带注释的标记 ,则需要确保新标记名称引用的是基础提交,而不是要删除的旧带注释的标记对象。)
Therefore, use git tag -a new old^{}
instead of git tag new old
(this is because annotated tags are objects while lightweight tags are not, more info in this answer ). (因此,请使用git tag -a new old^{}
代替git tag new old
(这是因为带注释的标签是对象,而轻量级的标签不是对象, 有关此信息,请参阅 )。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…