9

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?

royhowie
  • 10,605
  • 14
  • 45
  • 66
Suman Lama
  • 936
  • 1
  • 8
  • 25
  • https://stackoverflow.com/a/21050297/860421 strikes me as the best way to do this, but that answer does not seem to have caught enough attention. – 0xc0de Apr 09 '18 at 08:37
  • What about this https://stackoverflow.com/a/46645586/6839738 – blongho Nov 30 '20 at 09:53

2 Answers2

10

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
manojlds
  • 259,347
  • 56
  • 440
  • 401
5

Try this:

git commit -m 'Multi
line
message'
Sharvy Ahmed
  • 6,652
  • 1
  • 28
  • 43
  • 3
    In a command line, pressing enter ends the message. I think he wants to know how to actually put in a new line. – Kelvin Shadewing Jul 16 '17 at 00: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. – daemonexmachina Jan 23 '19 at 09:35