Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Tag, how to get editor like on commit for message?

Tags:

git

tags

As I get an editor (vi) when doing a git commit -m I'd like to get an editor doing

git tag myTagName -m

as my comment will contain code with quotes and I'd like to avoid escaping it!

like image 521
Pipo Avatar asked Jun 18 '19 11:06

Pipo


2 Answers

When tagging, give the parameter -a so git can see that this tag is "annotated", then git will open your editor to input the text.

For example:

git tag -a v1.0
like image 71
ΦXocę 웃 Пepeúpa ツ Avatar answered Sep 23 '22 04:09

ΦXocę 웃 Пepeúpa ツ


From the Git documentation:

If one of -a, -s, or -u <keyid> is passed, the command creates a tag object, and requires a tag message. Unless -m <msg> or -F <file> is given, an editor is started for the user to type in the tag message.

If -m <msg> or -F <file> is given and -a, -s, and -u <keyid> are absent, -a is implied.

Otherwise, a tag reference that points directly at the given object (i.e., a lightweight tag) is created.

As you may know, there are several kinds of tags in Git. When you used -m <msg>, you were implying -a (annotated tag). If you want to see the editor to provide the message, while still creating an annotated tag, simply use -a instead.

like image 25
Acorn Avatar answered Sep 23 '22 04:09

Acorn