10

I have been doing a oneline commit message for some time now but it doesn't give the entire information on the commit.

git commit -m "message"

I once used git Gui tool and it had option to do multiline commit message. One in header and one in detail. How do we do it from the command line?

And can some one explain any good practice to commit bug fix and new changes? I normally write "NEW:" or "FIX" at start of the commit message, i would like to know how you guys do this?

2

2 Answers 2

11

You can do from the command line:

git commit -m 'First line
Second line
Third line'

Alternatively, you can just let git trigger your editor by doing

git commit
2
  • Multiple lines get stuffed as one in Sublime Text Editor
    – user5306470
    May 22, 2017 at 2:59
  • use git config --global core.editor "subl -n -w" to write multiline message in sublime
    – Praneeth
    May 23, 2018 at 6:09
6

Try this:

git commit -m 'Multi
line
message'
2
  • 3
    In a command line, pressing enter ends the message. I think he wants to know how to actually put in a new line. Jul 16, 2017 at 0:15
  • 2
    @KelvinShadewing Specifically in Windows Command Prompt, that's true. This answer works in Bash, though. Bash assumes you haven't ended the command if you're in the middle of defining a string (i.e. you haven't closed the quotes). It also works in PowerShell, apparently.
    – daemone
    Jan 23, 2019 at 9:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.