DEV Community

Cover image for Good commit message V/S Bad commit message 🦾
Sourav Kumar
Sourav Kumar

Posted on

Good commit message V/S Bad commit message 🦾

When developers are pushing their code to VCS(Version Control System) such as Git. If you are working in any industry for production level code.

One should learn to write better commit message and make it a habit so that it is easy for co-developers to understand the code just by seeing the commit message.


You can use git log command to check all the commit messages, I bet you will come to see β€œYep… I have absolutely no idea what I meant by β€˜Fix style’ 6 months ago.” that doesn’t make any sense, what is fixed, what is the issue. πŸ₯΄


Structure of Git commit message

Condensed

git commit -m <message>
Enter fullscreen mode Exit fullscreen mode

Detailed

git commit -m <title> -m <description>
Enter fullscreen mode Exit fullscreen mode

Tips for writing commit message

  1. Use first letter as capital and rest as lowercase (title case).
  2. Use type of commit message e.g. bugfix, error, refactor, bump, config.
  3. Commit length of body must be 50 characters and description must be at least 72 characters.
  4. Be specific, don’t use worked, developed, thought, rather be direct, β€œfix”.

The commit type can include the following:

  • feat – a new feature is introduced with the changes
  • fix – a bug fix has occurred
  • chore – changes that do not relate to a fix or feature and don't modify src or test files (for example updating dependencies)
  • refactor – refactored code that neither fixes a bug nor adds a feature
  • docs – updates to documentation such as a the README or other markdown files
  • style – changes that do not affect the meaning of the code, likely related to code formatting such as white-space, missing semi-colons, and so on
  • test – including new or correcting previous tests
  • perf – performance improvements
  • ci – continuous integration related
  • build – changes that affect the build system or external dependencies
  • revert – reverts a previous commit

Top comments (0)