DEV Community

Quoc-Hung Hoang
Quoc-Hung Hoang

Posted on

3 1

Commit message with title and body with one-liner git command

When you use git, one of the most frequent used command is

git commit -m "my commit message"
Enter fullscreen mode Exit fullscreen mode

But most of the time, you would give a more meaningful commit message. Meaningful I mean here is that the message should consist of subject line (a short description of your changes in code) and body (to give more detailed description of what you did)

Today I learn that git commit accept multiple message flag 😉
If you run this command

git commit -m "subject line" -m "commit description"
Enter fullscreen mode Exit fullscreen mode

It will result in this

Author: hunghoang-saritasa <hung.hoang@saritasa.com>
Date:   Thu Aug 11 16:29:07 2022 +0700

    Subject line

    Commit message
Enter fullscreen mode Exit fullscreen mode

This new finding helps me save time a lot. No need to open a vim editor when committing message with subject and body. And actually the git documentation do mention it.

Bonus: Another way to achieve this commit message structure is opening quotes then press enter and closing the commit with quotes again
Image description

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay