Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git tag message template?

Is there a way to setup a git tag message template similar to the way the commit message template works?

With git config we could configure a template for commits, pointing to some .git-msg-template. This would, for example in ~/.gitconfig, look like this:

[commit]
  template = ~/.git-msg-template

However, if you read through the git documentation or simply lookup the git config tag.* options in terminal, there seems to be no git config tag.template, only git config commit.template setting.

Nevertheless, even without setting up a custom commit.template, the default message for commits and tags differs for me. Commits start with Please enter the commit message ..., add branch information and so on while tags simply have Write a message for tag: v1.0.0. Thus, internally, there should be different templates for commits and tags?!

like image 658
daniel451 Avatar asked Oct 20 '25 04:10

daniel451


1 Answers

There is no template file option for git tag; the template is hard coded into the Git source. There is, however, a -F argument that reads the message from a file. Note that git tag -m or git tag -F will skip running the editor unless you also add --edit. You could therefore get the effect you want using:

git tag --edit -F ~/.git-tag-template

(I suspect a patch that adds a template-file configuration to git tag, with the code similar to that in builtin/commit.c, would be welcome.)

like image 122
torek Avatar answered Oct 22 '25 00:10

torek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!