问题
Tags in git can apparently be moved from one commit to another by simply deleting them and then re-tagging.
For example:
git tag -m "Version 1.0" v1.0 abcd123
git push --tags
git tag -d v1.0
git tag -m "Corrected version 1.0" v1.0 1234abc
git push --tags
How do I see the entire history of a particular tag? (In other words, any time a tag with that name was created/deleted, and what commits each one pointed to)
How do I see the entire history of all tags?
回答1:
They can also be moved by force:
git tag -f ...
and then force-pushed.
How do I see the entire history of a particular tag? (In other words, any time a tag with than name was created/deleted, and what commits each one pointed to)
In general, you can't.
If a tag is force-moved and force-pushed and you keep reflogs for tags, you can retrieve previous values from the tag's reflog, until those reflog entries expire. Deleting a reference (any reference), however, deletes the reflog.
Annotated tags use objects within the repository (in addition to the reference itself). Deleting the reference deletes only the external tag-name reference to the annotated-tag object. As long as the underlying object itself has not been removed, you can access it by ID. As an unreferenced object, though, it is subject to the usual garbage-collection rules. Only if some additional reference (usually another tag-name for another annotated tag) keeps the original annotated-tag object reachable is it guaranteed to remain in the repository.
(There's no fundamental reason a tree object could not point to tag objects, so it would be possible to have a commit object that pointed to a tree that keeps old annotated tags around. But Git is not built to do this, and has no tools for constructing such things, and it's possible that git fsck
would consider them erroneous. So this is more a theoretical exercise: it would theoretically be possible to save, and persist, "old tags" and "tag history" through special commits, probably pointed-to through a new reference name space such as refs/tagarchive/
, if at least one Git plumbing command and several scripts were written. Of course this is all pure speculation until someone writes these. It's not clear how they would be useful, either.)
来源:https://stackoverflow.com/questions/39782489/how-to-show-full-history-of-tags-in-git