Photo by Praveen Thirumurugan on Unsplash
"Best Practices for Writing Clear and Concise Git Commit Messages: A Guide with Examples"
A good Git commits message should be clear and concise, describing the changes made in the commit. It should also include information about why the change was made.
Here is an example of a well-written commit message:
Fix bug in login form
The login form was not properly validating the entered credentials, causing users to be unable to log in. This commit fixes the issue by adding proper validation and error handling.
- Added validation for email and password fields
- Implemented error handling for invalid credentials
- Updated login form to display error messages
- Tested the fix and confirmed that login is now working properly
The first line briefly summarizes the commit, describing the main changes made. The following lines provide more detailed information about the changes and why they were made. The final line confirms that the changes have been tested and are working properly.
It's good practice to use the imperative mood when writing commit messages, for example, "Fix bug" rather than "Fixed bug" or "Fixes bug." Also, it's good to use the present tense.
When possible, it's also helpful to include specific details about the changes made, such as the names of files or functions that were modified.
Additionally, it's a good practice to keep the commit message limited to 72 characters on the first line and limit the whole message to 72 characters per line.