tags:

views:

1712

answers:

2

Today I was looking through the logs for a project and realized that I fat fingered a tag name some time ago. Is there some way to rename the tag? Google hasn't turned up anything useful.

I realize I could check out the tagged version and make a new tag, I even tried that. But that seems to create a tag object that isn't quite right. For one, 'git tag -l' lists it out of order relative to all of the other tags. I have no idea if that's significant, but it leads me to believe that the new tag object isn't quite what I want. I can live with that, because I really only care that the tag name matches the documentation, but I'd rather do it "right", assuming there is a right way to do this.

+6  A: 

If it's published, you can't delete it ( without risking being tarn and feathered, that is). The 'git way' is to do:

The sane thing. Just admit you screwed up, and use a different name. Others have already seen one tag-name, and if you keep the same name, you may be in the situation that two people both have "version X", but they actually have different "X"'s. So just call it "X.1" and be done with it.

Alternatively,

The insane thing. You really want to call the new version "X" too, even though others have already seen the old one. So just use git-tag -f again, as if you hadn't already published the old one.

It's so insane because:

Git does not (and it should not) change tags behind users back. So if somebody already got the old tag, doing a git-pull on your tree shouldn't just make them overwrite the old one.

If somebody got a release tag from you, you cannot just change the tag for them by updating your own one. This is a big security issue, in that people MUST be able to trust their tag-names. If you really want to do the insane thing, you need to just fess up to it, and tell people that you messed up.

All courtesy of the man pages

Robert Munteanu
Or you can tag (with correct name) this incorrectly named tag.
Jakub Narębski
Thanks, I've been over that man page a million times already. Fortunately the bad tag hasn't been published anywhere. Even if it was, this is an internal project and I'm the only developer (for the moment). I'm think I'm fairly safe from both the tarring and the feathering, but only if I can get the repo to match the docs.
Brandon Fosdick
+11  A: 

The original question was how to rename a tag, which is easy: first create NEW as an alias of OLD: "tag NEW OLD" then delete OLD: "tag -d OLD".

The quote regarding "the git way" and (in)sanity is offbase because it's talking about preserving a tag name but making it refer to a different repo state.

Greg McGary
That's how I always do it. Probably the easiest way.
Sam Soffes
i typo my tags all the time. i fix them your way too.
cjimti