DEV Community

Cover image for 7 Ways to Write Good commit message
Vansh Sharma
Vansh Sharma

Posted on

7 Ways to Write Good commit message

What is a commit message?

Brief description of the changes you made to the codebase. So that other members of the team can understand all changes you made to the codebase.

Why is it necessary to write a good commit message?

It is a good habit to write a good commit message because people come and go but code remains there. So you should commit in such a way that future members and the member of other teams can understand What all changes you have made?

Let's see an example of the GOOD & BAD Commit message.

  • Example1 carbon.png
  • Example 2

carbon (1).png

Points to remember while writing Commit message :

  1. Divide the commit message into 2 parts: subject and body.
    In the above Example 2 1st message is subject part and 2nd message is body part.

  2. Mention the type of commit you are making in Subject part such as:

    • Feat: For any new feature
    • Fix: If you fix any bug
    • Docs: Changes in documentation
    • Style: Any changes in style like color, design etc.
    • Refactor: When you refactor the code
    • Test: Anything related to testing
    • Chore: Regular code maintenance
  3. Limit the subject line to 50 characters.

  4. Don't end the subject line with a period (.)

  5. Use the Imperative mood in subject line

    Imperative mood is like giving orders. Like:

    • Fix the bug
    • Change background color
  6. Wrap the body part at 72 characters.

  7. Capitalize the subject line and each paragraph.

That's all for this blog. We will meet in the next blog until then Keep learning, Keep growing.

Connect with me :

Reference :

FreeCodeCamp
Neogcamp

Top comments (0)