git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 12, 2021, 16:08 UTC
Message-ID
<211112.86fss1uyxy.gmgdl@evledraar.gmail.com>
In-Reply-To
<04cbce68-bcbd-dbb2-5d9d-df7dd464fa03@gmx.com>
On Fri, Nov 12 2021, Eyal Rozenberg wrote:
Show 25 quoted lines
> 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.

Previous: Eyal Rozenberg
Message 2 of 2 in “Feature request: Ability to edit existing tag's message”
  1. Eyal RozenbergNov 12, 2021
  2. Ævar Arnfjörð BjarmasonNov 12, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.