DEV Community

Discussion on: Write Git Commit Messages That Your Colleagues Will Love

Collapse
 
annetawamono profile image
Anneta Wamono

When I commit with a message on the command line, I think I'm only able to add a subject line. Is there a way to add a commit body through command line?

Collapse
 
simeg profile image
Simon Egersand 🎈

I guess you do something like

git commit -m "Add field to schema"
Enter fullscreen mode Exit fullscreen mode

Instead you can do

git commit
Enter fullscreen mode Exit fullscreen mode

And git will open up your favorite editor (it defaults to $EDITOR I think) and you can put in a subject and body there. You separate them by a newline.

Collapse
 
algonzalez profile image
Al Gonzalez • Edited

You can use the -e or --edit option which will open your configured editor.
You can also use the -m option multiple times and the text will be concatenated as separate paragraphs.
Another method is to pipe the comment to a file and use either the -F <file> or --file=<file> option.

Running git help commit should show you all the possible options.

HTH