# Feature request: Ability to edit existing tag's message

2 messages from 2021-11-12 to 2021-11-12. Participants: Eyal Rozenberg, Ævar Arnfjörð Bjarmason.
Thread: https://gitlist.dev/t/56880

## Eyal Rozenberg, 2021-11-12 15:05

Subject: Feature request: Ability to edit existing tag's message
Message-ID: <04cbce68-bcbd-dbb2-5d9d-df7dd464fa03@gmx.com>
URL: https://gitlist.dev/e/04cbce68-bcbd-dbb2-5d9d-df7dd464fa03%40gmx.com

```
At the moment, one has to go through some hoops to edit a tag's message;
see discussions here:

https://stackoverflow.com/q/7813194/1593077

It would be nice if:

    git tag --edit my_tag_name

would bring up the editor with the existing text of my_tag_name's
message, for amendment. And, perhaps,

    git tag --edit my_tag_name -m "new message"

would overwrite the existing message. I've suggested `--edit` since the
switch already exists, but if you like a different bikeshed then it
could be --amend like git commit --amend.


Just my 2 cents and have a nice day,
Eyal Rozenberg


PS - I'm not on this mailing list, so if you want to reply, please use
my actual address.

```

## Ævar Arnfjörð Bjarmason, 2021-11-12 16:08

Subject: Re: Feature request: Ability to edit existing tag's message
Message-ID: <211112.86fss1uyxy.gmgdl@evledraar.gmail.com>
URL: https://gitlist.dev/e/211112.86fss1uyxy.gmgdl%40evledraar.gmail.com
In-Reply-To: <04cbce68-bcbd-dbb2-5d9d-df7dd464fa03@gmx.com>

```

On Fri, Nov 12 2021, Eyal Rozenberg wrote:

> At the moment, one has to go through some hoops to edit a tag's message;
> see discussions here:
>
> https://stackoverflow.com/q/7813194/1593077
>
> It would be nice if:
>
>    git tag --edit my_tag_name
>
> would bring up the editor with the existing text of my_tag_name's
> message, for amendment. And, perhaps,
>
>    git tag --edit my_tag_name -m "new message"
>
> would overwrite the existing message. I've suggested `--edit` since the
> switch already exists, but if you like a different bikeshed then it
> could be --amend like git commit --amend.
>
>
> Just my 2 cents and have a nice day,
> Eyal Rozenberg
>
>
> PS - I'm not on this mailing list, so if you want to reply, please use
> my actual address.

Yes, these should be an easier way to do that.

In the meantime it seems a lot of those suggestions on Stack Overflow
are way too complex, since they're struggling to maintain all the tag
metadata as-is, an easier way is:

    git cat-file tag <tag-name> | sed s/foo/bar/g | git mktag

Which will create and print out the OID of a tag object, if nothing is
changed the OID is the same, then just:

    git tag <tag-name> <that-oid>

Where you'll need a --force if the <tag-name> is the same.

It's not as "safe" as e.g. "git commit --amend", as you can edit the raw
headers, but for people who want this that may be a feature most of the
time.

It will also preserve the inline PGP signature, which if you make any
edits to the tag won't verify anymore.

It also looks like a lot of those SO answers pre-date my not-so-recent
changes to "fetch" where we'll by default error if any existing tags
would be clobbered.

So you can do this, but there's a reason for why it's not
implemented. I.e. you really don't want to edit existing tags in the
general case.

But I can see how it's useful if you've not pushed it out, or if
changing it is OK in your environment even if it was pushed out.

```
