I am using Git from the command line and am trying to add a line break to the commit message (using git commit -m ""
) without going into Vim.
Is this possible?
- Fixed a bug Another method of adding a multi-line Git commit message is using quotes with your message, though it depends on your shell's capacity. To do this, add single or double quotes before typing the message, keep pressing enter and writing the next line, and finally close the quote at end of the message.
The git commit command captures a snapshot of the project's currently staged changes. Committed snapshots can be thought of as “safe” versions of a project—Git will never change them unless you explicitly ask it to.
Certainly, how it's done depends on your shell. In Bash, you can use single quotes around the message and can just leave the quote open, which will make Bash prompt for another line, until you close the quote. Like this:
git commit -m 'Message goes here'
Alternatively, you can use a "here document" (also known as heredoc):
git commit -F- <<EOF Message goes here EOF
If you just want, say, a head line and a content line, you can use:
git commit -m "My head line" -m "My content line."
Note that this creates separate paragraphs - not lines. So there will be a blank line between each two -m
lines, e.g.:
My head line My content line.
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