back to Today I Learned page

Multiple paragraphs on "git commit -m" command

posted at 07-07-2020

Sometimes I go to commit something and I don't want to open the editor (vim in this case) to add my thoughts, that's because sometimes we're able to explain what we're doing in some couple of words.

But sometimes we feel that we should add something more to really explain what we're doing on that commit, as we need to keep 72 (50 preferable) characters on the title, it's not possible to leave that on the commit title, and sometimes we shouldn't, as it isn't on the context of the title.

So I go and open vim, even if It's "a simple commit", because I need to add more paragraphs to explain my changes.

The thing is, I was going around Twitter and I saw a tweet from @stefanjudis saying that we can use multiple "-m" when doing a git commit

So next time that you want to do a commit on the command line, and not open a editor, you can do something like:

$ git commit -m "This is the title" -m "This is the second paragraph"

Another way, that I already knew but I keep forgetting it, is leaving the quote open:

$ git commit -m "This is a title
$ dquote>
$ dquote>This is the second paragraph
$ dquote>
$ dquote>This is the third paragraph"

Either way, thanks for @stefanjudis for raising up this, if you want to check this TIL post click here.