How do I add multi-line messages using
git commit -a -m "..."
The answer from this similar question appears to work (judging by the upvotes and acceptance), but it seems a bit cumbersome1.
The git documentation reads:
-m <msg>
--message=<msg>
Use the given <msg> as the commit message. If multiple -m options are given, their values are concatenated as separate paragraphs.
So, would it be advisable to just use a new -m
for each new line of the message? Or do "paragraphs" add additional line spacings?
It would be nice if future versions of the command would allow us to just add \n
between sentences, to denote line breaks.
1 The linked answer basically advises to use a message template file, and direct git to use the file via git commit -t <template_file>
The answer may depend on what shell you use to run git. For example with bash (just tested this on windows using the bash shell installed with git):
git commit -m "this is
a multi-line
message"
because quite simply bash will not assume that hitting return ends the command if it's in the middle of a quoted string.
That said, I've only ever used -m
for one-line messages; other options just "make more sense" to me if I need a multi-line message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With