Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

commit

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?

like image 982
fernando Avatar asked Apr 29 '15 02:04

fernando


People also ask

How do you modify the message of a commit?

On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter. In your text editor, edit the commit message, and save the commit.

Can commit messages have spaces?

Git commit -m does not accept spaces in the message [closed] Bookmark this question.

How do I change multiple commit messages in git?

To change the most recent commit message, use the git commit --amend command. To change older or multiple commit messages, use git rebase -i HEAD~N . Don't amend pushed commits as it may potentially cause a lot of problems to your colleagues.


Video Answer


1 Answers

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 
like image 194
Alex Pan Avatar answered Sep 30 '22 10:09

Alex Pan