# How to write a good commit message

Writing a good commit message is essential for maintaining a clear and organized version control history. Writing a good commit message saves you a lot of time and your colleagues while troubleshooting by giving helpful descriptions. You must follow your teams' conventions while writing a commit message.

Here are some general tips for writing a good commit message;

* **Use a descriptive subject line** \- the subject line should explain the purpose of the commit message. It should be clear and informative. Providing a summary of changes made.
    
    ```markdown
    ✅ Add user authentication feature
    ```
    
* **Keep it concise** - You should provide a lot of information in a few words for example
    
    ```markdown
    ✅ Fix typo in login form
    ```
    
* **Provide context** - in the body of the commit message you should provide additional context about the message. Explain why the changes were made, what problem they solve, and how they affect the codebase
    
    ```markdown
    ✅ Update database schema to improve performance
    This commit updates the database schema to optimize query performance, by adding indexes to frequently queried columns
    ```
    
* **Use imperative mood** - this expresses a command or gives instructions. for example, say 'Fix bug' instead of 'fixing bug' or 'fixed bug'
    

```markdown
✅ Update README.md with installation instructions
```

* **Use present tense** \- write the subject line and body of the commit message using present tense to maintain consistency and clarity. for example 'Implement a new search functionality'
    
* **Separate the subject from the body** \- this action in turn helps with improving readability and makes it easier to scan commit history.
    

```markdown
✅ Add user authentication feature

This commit adds a new authentication module to the application, allowing users to securely log in and access protected resources.
```

* **Proofread**\- Before committing a message take a minute to read your commit message for any typos or errors. This demonstrates professionalism and attention to detail.
    
* **Follow project conventions** \- If your project has specific guidelines on how to write a commit message make sure to follow them consistently.
    
* Length - The length of the first line should not be more than 50 characters. the body should be restricted to 72 characters.
    
* Capitalization and punctuation - The first word should start with a capital letter and not end with a punctuation.
    
    ```markdown
    ✅ Add new feature to improve user authentication
    
    This commit adds a new feature to enhance user authentication by implementing two-factor authentication for added security.
    ```
