DEV Community

Tom Metten
Tom Metten

Posted on

Refactor commit message for better readability

Writing good commit messages is an important part of any software development process. Not only do they provide valuable information about the changes made to the code, but they also help to document the history of the project and make it easier for other developers to understand and work with the code.

One of the key recommendations for writing good commit messages is to follow a specific format. This typically includes a subject line that concisely summarizes the change, followed by a blank line and then a more detailed description of the change. The subject line should be written in imperative mood, as if you are giving an order or command, and should be no longer than 50 characters.

Here is an example of a well-formatted commit message:

Fix bug in login page

The login page was not properly validating user input, which allowed
attackers to bypass the authentication process. This commit fixes the bug
by properly sanitizing user input and implementing additional validation
checks.

Enter fullscreen mode Exit fullscreen mode

In terms of writing style, it is important to be concise and clear in your commit messages. Avoid using jargon or technical terms that may not be understood by everyone on the team, and try to provide enough information to give context to the changes you have made. It can also be helpful to include links to relevant issues or references in the detailed description.

Different platforms, such as Git and GitHub, have their own ways of interpreting and displaying commit messages. For example, Git will typically only display the subject line of the commit, while GitHub will display the full commit message and may highlight certain keywords or phrases. In both cases, following the recommended format and writing style will make it easier for the platform to interpret and display the commit message in a useful and readable way.

In conclusion, writing well-composed commit messages is an essential part of any software development process. By following a specific format and writing style, you can ensure that your commit messages are clear, concise, and easy to understand, making it easier for other developers to work with your code and understand the history of the project.

Top comments (0)