Search code examples
gitcommit

How can I make git commit messages divide into multiple lines?


When I use git log to check out my commit explanatory note I want it to look like this:

1. what I changed
2. blank line
3. why I changed it

...being in 3 lines not 1 like this:

1. what i changed  2. blank line 3. why i changed

However, git log shows it in one line. So, how do I get this to happen using git commit -m?


Solution

  • 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