Reputation: 851
How can I use git filter-branch
to modify tag messages? Using the --msg-filter
option appears to only modify regular commit messages, but not messages of annotated tags.
Upvotes: 0
Views: 290
Reputation: 488103
You can't. But that doesn't matter, because there's no point.
What git filter-branch
does is to add new commits to a repository. In general, you take an existing repository full of commits, identify one or more "bad" ones, and tell Git: For every commit, extract that commit, fix it if it's bad, and then turn that into a new commit. If the new commit is 100% identical, bit-for-bit, to the original—if the filter made no changes at all—Git winds up re-using the original commit. Otherwise, Git makes a new and improved commit, that has whatever was wrong with the original corrected and/or refers to the other new commits instead of the icky old ones.
Your job is to make a new tag (of type annotated tag) that refers to the same old existing commit as the previous tag (also of type annotated tag). You don't need to add any new commits.
To do what you want, just make the new tag. You'll need to rename or delete the old annotated tag first, to get it out of the way. There is no command to rename a tag (if it's unpacked you can cheat, but if it has been packed this won't work), so that means you essentially need to delete the old tag. Be sure to save the target commit hash first, because deleting the tag will make it impossible1 to find again.
Hence:
git rev-parse existing-tag^{commit}
to get the commit hash ID, then:
git tag -d existing-tag
then:
git tag -a existing-tag hash
where the hash
is the big ugly hash ID printed by the git rev-parse
.
1Technically, you can find it, but it's much too hard, especially because git fsck
won't save unreferenced tag objects into a lost-found
directory like it does for unreferenced commits and blobs.
Upvotes: 2