How can I make git commit messages divide into multiple lines?
I find it much easier to save the commit message to a file, and then use the -F option.
Example:
$ cat > /tmp/commit_msg.txt
DE123 bug fix: incorrect fetching of instance details
- fixed this and that
- also did such and such
$ git commit -F /tmp/commit_msg.txt
You could also use an editor to edit the message file before the commit.
You just use the following command:
$ git commit -m "1. what i changed
> 2. blank line
> 3. why i changed"
In your terminal, just hit 'enter' for a new line. The commit message won't end until you add the closing quote. The git log will look like:
$ git log
commit abcde2f660c707br2d20411581c4183170c3p0c2
Author: Alex Pan <[email protected]>
Date: Tue Apr 28 20:52:44 2015 -0700
1. what i changed
2. blank line
3. why i changed
Use two --message
/-m
options, first one for the subject and second one for the body.
Excerpt from documentation:
-m <msg> --message=<msg>
Use the given as the commit message. If multiple -m options are given, their values are concatenated as separate paragraphs.
In your case it does exactly what you want, inserts a blank line between first and second lines.
git commit -m "Subject: what I changed" -m "Body: why I changed it"
This is useful if you want to amend previously added comment.
The multiple-line format you describe is the recommended one with Git (See DISCUSSION in the documentation of git commit). The simplest way to do it is to use git commit
without -m
, and write your message in your text editor.