How to add newline characters in git tag messages

When I mark version code in git, I like to use marker dots in the tag message.

This can be easily done using annotated tags:

git tag -a v1.0.0 * Change number 1 * Change number 2 # # Write a tag message # 

However, if I try to use the same tags with the -m option, the tag message is not what I expect:

 git tag -a v1.0.0 -m "* Change number 1\n* Change number 2" git show v1.0.0 ... * Change number 1\n* Change number 2 .... 

"\ n" was interpreted literally as the characters "\" and "n" instead of a new line. I want to use the -m option so that I can automate the marking process.

Is it possible to include actual newlines using the git tag with the -m option?

+6
source share
3 answers

The closest solution I have found is to use several -m options, one for each line. For instance:

 git tag -a v1.0.0 -m "* Change number 1" -m "* Change number 2" 

from git -tag man page :

 -m <msg> Use the given tag message (instead of prompting). If multiple -m options are given, their values are concatenated as separate paragraphs. (...) 

UPDATE : check Add a line break in git commit -m from the command line for more shell-based solutions.

+9
source

Another alternative would be to put a formatted message in a (temporary) file and use git tag -F <filename> <tag> to read the message from this file.

+4
source

Assuming you are using a unix shell, your syntax for the new line is incorrect.

 git tag -a v1.0.0 -m "* Change number 1 * Change number 2" 

must work.

0
source

Source: https://habr.com/ru/post/916286/


All Articles